mike12255 Posted June 14, 2009 Share Posted June 14, 2009 im trying to use info from my db to create a link, but its just creating a link to the page its already on, anyone know why? <?php $sql = "SELECT * FROM catagories"; $res = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_assoc($res)){ echo "<a href='".$row['name']."'>".$row['wantedname']."</a><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/162167-solved-linking-wrong/ Share on other sites More sharing options...
wildteen88 Posted June 14, 2009 Share Posted June 14, 2009 What is the output of that code? Where should the user go when they click the link. You need to be more specific. Quote Link to comment https://forums.phpfreaks.com/topic/162167-solved-linking-wrong/#findComment-855783 Share on other sites More sharing options...
mike12255 Posted June 14, 2009 Author Share Posted June 14, 2009 well for example row['name'] of the first object in the db is: ../pfd/Martial Arts - Pressure Points - Military Hand To Hand Combat.pdf and row['wantedname'] is: Testing so the first link should be <a href= "../pfd/Martial Arts - Pressure Points - Military Hand To Hand Combat.pdf">Testing</a> however the source its outputting for it is: <a href="">Testing</a><br> its not linking it to anything Quote Link to comment https://forums.phpfreaks.com/topic/162167-solved-linking-wrong/#findComment-855800 Share on other sites More sharing options...
wildteen88 Posted June 14, 2009 Share Posted June 14, 2009 Are your sure there is a field called name in your catagories table? Quote Link to comment https://forums.phpfreaks.com/topic/162167-solved-linking-wrong/#findComment-855804 Share on other sites More sharing options...
Andy-H Posted June 14, 2009 Share Posted June 14, 2009 <?php error_reporting(E_ALL); $sql = "SELECT * FROM catagories"; $res = mysql_query($sql) or die (mysql_error()); while ( $row = mysql_fetch_assoc($res) ) { echo "<a href=\"" . urlEncode($row['name']) . "\">" . $row['wantedname'] . "</a><br >\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/162167-solved-linking-wrong/#findComment-855806 Share on other sites More sharing options...
mike12255 Posted June 14, 2009 Author Share Posted June 14, 2009 ...wildteen was right. i guess i accidently hit shift when i was making my DB cause name is actually Name Quote Link to comment https://forums.phpfreaks.com/topic/162167-solved-linking-wrong/#findComment-855808 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.