views:

739

answers:

2

I have a mysql table containing the values for 'display' and 'link'.

I'd like to pull these into a php file that displays the 'display' value which hyperlinks to the 'link' value

I have already connected to the database and selected the appropriate rows to display, but I'm at a loss on how to create the php for this..

As you can probably tell, I'm a complete noob so simplicity is appreciated in any answers.. thanks for the help!

+3  A: 

like so?

$row = mysql_fetch_assoc($result);
echo '<a href="'.$row["link"].'">'.$row["display"].'</a>';
davethegr8
i think that's it.. thanks!
jwb
+1  A: 

One addition to the previous posters code. You'll want to escape the values before outputting them to prevent html injection attacks (and general wonkiness if special characters are in the links or titles).

$row = mysql_fetch_assoc($result);
echo '<a href="'.htmlspecialchars($row["link"]_.'">'. htmlspecialchars($row["display"]).'</a>';
Daniel Von Fange
great addition.. thanks
jwb