The following code block is from a site I'm developing for a local museum.
The site is now located at  but will move
eventually to its own site.  In it, I have a list of the landmark trees,
with links to a map showing the location of the tree, a link to to get a detailed map of the location and or driving
directions, and links to show all the trees in an area of the city.  In
other words, the table is link crazy--sounded enough like what you want to
do that I responded to your question.  All of the data in the html table
comes from a mysql database with three database tables (heritage, trees,
If you use the mysql_fetch_array() command in a WHILE statement, you create
an array of the row or rows resultant from your query and have the mysql
column titles as your array keys.  You can then use the <a href= html tag to
put a link under the words in your table cells and generate the html code to
go to the next row of data.
As I said earlier, I have the bad habit of writing everything in php once I
need it on a page, so the code block might be a bit hard to read.  Let me
know if you need further details on what's provide.
Hope this helps,

print "<table align=center bgcolor=white cellspacing=0 cellpadding=4
border=1 >";
 print "<tr bgcolor=Cornsilk><td><h5><b>ID # <a href=list.php
title=\"scientific name\"><b>Common

 if (! $link) die("Can't log in at this time");
 mysql_select_db($db,$link) or die ("Can't log in at this time");
 $query="select * from heritage where asset_num>'0' order by asset_num";
 if (!$result) die(mysql_error());
 while ($heritage=mysql_fetch_array($result))
  $query2="select * from trees where id='".$heritage['plant_num']."' ";
  $query3="select * from sites where plant_num='".$heritage['plant_num']."'
  while ($sites=mysql_fetch_array($result3))
  print "<tr><td valign=top align=left><p><a
y=".$heritage['y']." title=\"".stripslashes($trees['scientific_name'])."
native to ".$trees['native_to']."\"> &nbsp;".$heritage['asset_num']."
       <td valign=top align=left><p><a
w&addr=".ereg_replace (" ", "+",
t%A0Map=Get+Map title=\"go to to get a map of this address\">
       <td valign=top align=left><p><a
href=mapmastr.php?district=".$heritage['town_name']." title=\"see the
location of all Landmark Trees in the ".$heritage['town_name']." District\">
print "</table>";

----- Original Message -----
From: "Andre Dubuc" <[EMAIL PROTECTED]>
Sent: Saturday, March 09, 2002 4:12 PM
Subject: [PHP] Selecting a Queried Row

> As a newbie at PHP (and relative newcomer to HTML and web design) I've
> wading through documentation trying to accomplish various tasks. However,
> stumped on how to proceed with the following:
> I would like a web vistor to be able to select a row from a table that has
> been generated from a query. The problem is I don't know how to code a
> paricular column (using the present <td> . . </td> syntax of the table) so
> that each cell would have a "clickable" element (perhaps the 'ID' number).
> Once that cell is clicked, I would like to code 'onclick=some_function()'
> Does this sound reasable way of approaching the problem, or is there a
> way. [Btw, at present, while learning PHP, I am using global_variables=on,
> but would like to try $PHP_SELF method to pick up session variables.]
> Any help would be greatly appreciated, as well as pointers of where to
> Tia, Andre
> --
> Please pray the Holy Rosary to end the holocaust of abortion.
> Remember in your prayers the suffering souls in Purgatory.
> May God bless you abundantly in His love!
> For a free Cenacle Scriptural Rosary Booklet --
> --
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to