Ramtree Posted July 16, 2009 Share Posted July 16, 2009 i need to random an entry where question_answered = $_POST['randompick'] (the form). $r_pick = $_POST['randompick']; $randomvar = "mysql_query(SELECT * FROM quiz_correct_response WHERE question_answered = $r_pick ORDER BY rand() LIMIT 1)"; while($pick = mysql_fetch_array($randomvar)) { echo $pick[0]; } but somehow it's giving me error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource please help me if you can, thanks Link to comment https://forums.phpfreaks.com/topic/166173-random-specific-entry-from-database/ Share on other sites More sharing options...
ignace Posted July 16, 2009 Share Posted July 16, 2009 $randomvar = "mysql_query(SELECT * FROM quiz_correct_response WHERE question_answered = $r_pick ORDER BY rand() LIMIT 1)"; should be: $randomvar = mysql_query("SELECT * FROM quiz_correct_response WHERE question_answered = $r_pick ORDER BY rand() LIMIT 1"); Link to comment https://forums.phpfreaks.com/topic/166173-random-specific-entry-from-database/#findComment-876364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.