Andre,

The following code block is from a site I'm developing for a local museum.
The site is now located at www.ironorchid.com/museum/  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
maps.yahoo.com 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,
sites).
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,
Hugh

<?php
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
Name</b></a></h5></td><td><h5><b>Address</b></h5></td><td><h5><b>District</b
></h5></td></tr>";

 $db="some_database";
 $pass="some_password";
 $link=mysql_connect("localhost","","$pass");
 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";
 $result=mysql_query($query);
 if (!$result) die(mysql_error());
 while ($heritage=mysql_fetch_array($result))
  {
  $query2="select * from trees where id='".$heritage['plant_num']."' ";
  $result2=mysql_query($query2);
  $trees=mysql_fetch_array($result2);
  $query3="select * from sites where plant_num='".$heritage['plant_num']."'
";
  $result3=mysql_query($query3);
  $num=0;
  while ($sites=mysql_fetch_array($result3))
   {
   $links[$num]=$sites['link'];
   $num=$num+1;
   }
  print "<tr><td valign=top align=left><p><a
href=mapmastr.php?list1=1&tree=1&coordinate_x=".$heritage['x']."&coordinate_
y=".$heritage['y']." title=\"".stripslashes($trees['scientific_name'])."
native to ".$trees['native_to']."\"> &nbsp;".$heritage['asset_num']."
&nbsp;".stripslashes($trees['common_name'])."</a></p></td>
       <td valign=top align=left><p><a
href=http://maps.yahoo.com/py/maps.py?BFCat=&Pyt=Tmap&newFL=Use+Address+Belo
w&addr=".ereg_replace (" ", "+",
stripslashes($heritage['address']))."&csz=".$heritage['zip']."&Country=us&Ge
t%A0Map=Get+Map title=\"go to maps.yahoo.com to get a map of this address\">
&nbsp;".stripslashes($heritage['address'])."</a></p></td>
       <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\">
&nbsp;".$heritage['town_name']."</a></td></tr>";
  }
 mysql_close($link);
print "</table>";
?>

----- Original Message -----
From: "Andre Dubuc" <[EMAIL PROTECTED]>
To: <[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
been
> wading through documentation trying to accomplish various tasks. However,
I'm
> 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
better
> 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
look!
>
> 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 --
http://www.webhart.net/csrb/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to