Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a link from text in MySQL database

Status
Not open for further replies.

martinb7

Programmer
Jan 5, 2003
235
GB
Hi, does anyone know how to get text out of a database, loop for multiple records, then print on the screen?

Is there a hyperlink type in mysql?

Code:
$conn = mysql_connect($host, $user, $pass);
mysql_select_db($db, $conn);
$query = mysql_query("SELECT link, linkurl FROM links");


while(list($var) = mysql_fetch_row($query)) { //multiple with loop
echo $var(&quot;<a href=$linkurl>$link</a>&quot; ).&quot;<br>&quot;;
}
?>
What am I doing wrong??

Please help!

Martin
 
Try this...

while ($r = mysql_fetch_array($query)) {
$link = $r[&quot;link&quot;];
$link_url = $r[&quot;link_url&quot;];

echo(&quot;<a href=\&quot;$link_url\&quot;>$link</a>&quot;);
}




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top