PDA

View Full Version : php mysql help.....


stevenl
2002-11-04, 08:36
Guys. I need some help here.

I was doing this script for php with mySQL.

I got stuck at one problem.

I have this database(testDB), table(testTable) and fields(unique_number, name and telephone number).

I have a while loop going to fetch information with sql query and present it in a listing form.

Example of the listing.

Unique_number Name Tel
------------------- --------- ----------
0001 abc 12345
0002 def 12345
0003 fgre 123232
......

and so on.

I would like to be able to click on one of the unique_number and it will bring me to a more details screen. How can I do that with php??

thanks alot!

HedgeHog
2002-11-04, 19:25
Hi,

There are several ways to do this, here is one:

just create a link to the page and pass the unique_number as a variable

<table>
<?PHP
db connect
$sql = "select * from testTable";
while ($result = mysql_fetch_array($sql)) {

print "<tr><td><a href=\"page_to_go_to.php?id=$result[unique_number]\">$result[unique_number]</a></td>";
print "<td>$result[name]</td>";
print "<td>$result[telephone]</td></tr>";

}
?>
</table>

and then on the page_to_go_to.php just call the information from your db using the $id variable:

$sql = "select * from testTable where unique_number='$id'";

HedgeHog

stevenl
2002-11-05, 13:52
thanks!...will try it out.

Thanks for the tip.