morocco-iceberg Posted May 23, 2010 Share Posted May 23, 2010 How can I make it so that these both pull information from the same row, whilst still making sure the row chosen is random? Everything I have tried hasn't worked. *mysql database row... function vocabularyAnswers($table){ $$table = mysql_query('SELECT * FROM '.$table.' ORDER BY RAND()') or die(mysql_error()); $i = 0; $row = mysql_fetch_array($$table); $answer_a[$i] = $row['a']; $answer_b[$i] = $row['b']; $answer_c[$i] = $row['c']; $answer_d[$i] = $row['d']; $answer_e[$i] = $row['e']; echo "<option value=\"".$answer_a[$i]."\">".$answer_a[$i]."</option>"; echo "<option value=\"".$answer_b[$i]."\">".$answer_b[$i]."</option>"; echo "<option value=\"".$answer_c[$i]."\">".$answer_c[$i]."</option>"; echo "<option value=\"".$answer_d[$i]."\">".$answer_d[$i]."</option>"; echo "<option value=\"".$answer_e[$i]."\">".$answer_e[$i]."</option>"; $i++; } function vocabularyQuestions($table){ $$table = mysql_query('SELECT * FROM '.$table.' ORDER BY RAND()') or die(mysql_error()); $i = 0; while($row = mysql_fetch_array($$table)){ $question_a[$i] = $row['a']; $question_b[$i] = $row['b']; $question_c[$i] = $row['c']; $question_d[$i] = $row['d']; $question_e[$i] = $row['e']; $i++; } echo "<input type=\"hidden\" name=\""; echo $table; echo "_q0\" value=\""; echo $question_a[0]; echo "\">"; echo "<input type=\"hidden\" name=\""; echo $table; echo "_q1\" value=\""; echo $question_a[1]; echo "\">"; echo "<tr><td>"; echo $question_a[0]; echo " / "; echo $question_b[0]; echo " / "; echo $question_c[0]; echo " / "; echo $question_d[0]; echo " / "; echo $question_e[0]; echo "</td><td><select name=\""; echo $table; echo "_a0\">"; echo "<option value=\"0\">Please select an answer...</option>"; vocabularyAnswers($table); echo "</select></td></tr><tr><td>"; echo $question_a[1]; echo " / "; echo $question_b[1]; echo " / "; echo $question_c[1]; echo " / "; echo $question_d[1]; echo " / "; echo $question_e[1]; echo "</td><td><select name=\""; echo $table; echo "_a1\">"; echo "<option value=\"0\">Please select an answer...</option>"; vocabularyAnswers($table); echo "</select></td></tr>"; } Quote Link to comment Share on other sites More sharing options...
morocco-iceberg Posted May 23, 2010 Author Share Posted May 23, 2010 Nevermind... for some reason my head wasn't working very well, did it a different way than I wanted to but got the same result. Quote Link to comment 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.