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? Quote 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); Quote 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>"; Quote 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"; Quote Link to comment https://forums.phpfreaks.com/topic/246915-php-and-links/#findComment-1268029 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.