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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.