davidf85 Posted September 11, 2011 Share Posted September 11, 2011 I am trying to create a link with an ID from one of my MySQL records. $data = mysql_query("SELECT * FROM USERS"); $info = mysql_fetch_array($data); echo "<a href=a.php?'$info['id']'>hello</a>"; is what I am attempting, but this does not work. Any ideas? Link to comment https://forums.phpfreaks.com/topic/246915-php-and-links/ Share on other sites More sharing options...
harristweed Posted September 11, 2011 Share Posted September 11, 2011 $info = mysql_fetch_array($data); Should be: $info = mysql_fetch_array($data, MYSQL_ASSOC); http://es2.php.net/manual/en/function.mysql-fetch-array.php but I think better to use: $info = mysql_fetch_assoc($data); Link to comment https://forums.phpfreaks.com/topic/246915-php-and-links/#findComment-1268027 Share on other sites More sharing options...
voip03 Posted September 11, 2011 Share Posted September 11, 2011 echo "<a href='a.php?id=".$info['id']."'>hello</a>"; Link to comment https://forums.phpfreaks.com/topic/246915-php-and-links/#findComment-1268028 Share on other sites More sharing options...
Pikachu2000 Posted September 11, 2011 Share Posted September 11, 2011 To insert an associative array element into a quoted string, use complex notation; enclose it in curly braces. echo "this is an {$array['element']} in a string"; Link to comment https://forums.phpfreaks.com/topic/246915-php-and-links/#findComment-1268029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.