Forum Moderators: coopster

Message Too Old, No Replies

MySQL table with links?

         

johnnybt

5:24 pm on Jan 25, 2004 (gmt 0)

10+ Year Member



I want to have a table displayed via a php page where the first column is linked to a page with just that entries information. like:

Name Age
John 3
Susie 6
Bill 7

So you can click on John and it brings up all his information in the database. How can I do this, or learn how to do this?

lasko

7:20 pm on Jan 25, 2004 (gmt 0)

10+ Year Member



Hi johnnybt

Firstly make sure you can pull the information properly from the Mysql database and display it on a web page nicely using the echo statements in php.

When creating the name column just simply in the html create a link to another page. Something like:

<?php echo"<a href='result.php?id=$name'>$name</a>";?>

When clicked the $name will be sent to the result.php page and this will be the page programmed to extract all the information about $name.

In the result.php page just do a simple

$query = "select * from table where name ='$name'";

Hope this helps a little.

johnnybt

11:32 pm on Jan 25, 2004 (gmt 0)

10+ Year Member



My table is coming up fine, but I'm a little lost on your message

"When creating the name column just simply in the html create a link to another page."

I don't know exactly what that means. When you say "when creating the name colum", where in my code am I creating this column? I just dont know where to put the code. And is it its own php script, or can i strip the <? off it and just plug it inside the rest of the page?

thanks

lasko

11:46 am on Jan 26, 2004 (gmt 0)

10+ Year Member



php allows you to create a normal html page and you can insert <?php?> any where within a normal html file.

So when designing your table results create it in normal html

Then insert your php statement <?php?> where you want the result to appear!

<table>
<tr>
<td>
<?php echo"<a href='results.php?name=$name'>$name</a>";?>
</td>
</tr>
</table>

This <?php echo"<a href='results.php?name=$name'>$name</a>?> should create a link to another page and when clicked it will be sending the name of the person through the url, that will tell your results.php page which name to get abstract from the database.

I think you are looking at it to hard, remember you can insert <?php?> any where with in a html file. instead of just echoing normal text you echo a link!