0

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>';
3
  • 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'] Commented Jul 4, 2012 at 10:41
  • Thank you very much! and in the new page will i be able also to display the genre and specialty and some more columns that the specific name have? Commented Jul 4, 2012 at 10:47
  • I posted as an answer :) Commented Jul 4, 2012 at 10:50

2 Answers 2

1

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 :)

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you! But what is it going to echo?
I might have a problem. The entries in Mysql database have utf8 encoding and where i have space it stops the link. For example here is the results page /Search_Results.php and whe i click the name to redirect me when it's in Greek, it shows like this: /profile.php?Fname="Χρήστος while the link should be: /profile.php?Fname="Χρήστος Καραπετσάκος" Any ideas about this?
Probably you'll need to use htmlentities() Just like: href=pageyouwant.php?fname="'.htmlentities($row['fname']).'">
Yeah it works but it gives me symbols in the link. how to set the characters to utf-8 for the htmlentities?
0

Use this line:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.