Stavros Backwards
Stavros Backwards

Reputation: 67

php make link from mysql results

How can i make the $row['Fname'] to be a link and when i click it, redirect me to a new page with more info about this entry i clicked?

here is the code:

echo '<ol>'; 
while ($row = mysql_fetch_array($sql)){

echo '<li>';
echo '<img src="'.$row['Bio']. '" alt="" width="110" height="110">';
echo '  <dl>';
echo '  <dt>Name</dt>';
echo '  <dd>'.$row['Fname'].'</dd>';
echo '  <dt>Genre</dt>';
echo '  <dd>'.$row['Genre'].'</dd>';
echo '  <dt>Speciality</dt>';
echo '  <dd>'.$row['Specialty'].'</dd>';
echo ' </dl>';
echo '</li>';

}
echo '</ol>';

Upvotes: 0

Views: 3856

Answers (2)

silentw
silentw

Reputation: 4885

just wrap it using

<dd><a href=pageyouwant.php?fname="'.$row['Fname'].'">'.$row['Fname'].'</a></dd>

and then in the pageyouwant.php just grab that variable using $_GET['fname']

pageyouwant.php

$fname = $_GET['fname'];

$sql = "SELECT * FROM table WHERE fname LIKE '%$fname%'";

Using this in php, you can get all the info regarding the fname :)

And then you're all set :)

Upvotes: 1

Shehzad Bilal
Shehzad Bilal

Reputation: 2523

Use this line:

echo '  <dd><a href="'.$row['id'].'">'.$row['Fname'].'</a></dd>';

Upvotes: 0

Related Questions