Jump to content

How do I display information from a row through a link?


phpnoobie9

Recommended Posts

I have the names listed as a link through a loop.

<?php while($whileloop = mysql_fetch_array($catresults)) {
?>
<a href="#"><?php echo $whileloop['name'].'<br />'; ?></a>
<?php
} 
?>

 

When I click the link..how do I get it to display some information from the row?

 

You need to use a $_GET statement.

 

So your URL should be

 

mypage.php?name=joe

 

Then you use $_GET['name']

 

You would then query your DB on that name and retrieve/display whatever info you're looking for.

Best off using id in case of two names the same:

 

<ul>
<?php 
while($whileloop = mysql_fetch_array($catresults)) {
$name = $whileloop ["name"];
$id= $whileloop ["id"];

echo"</li><a href=\"details.php?id=$id\">$name</li></a>";

} 
?>
</ul>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.