Jump to content

Pull information from same row for two seperate functions?


Recommended Posts

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>";
		}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.