From a select query I get returned a single record, which is fine.....as below:
// Retrieve all the data from the table $result = mysql_query("SELECT question FROM kanji.sentence WHERE id = '$id'") // store the record of the table into $row $row = mysql_fetch_array( $result ); echo "$row[question]";
Now, in the sentence table there are 6 possible answers to the question posed , and only one of them is correct. 'Item_1' is always the correct answer. What I want to do is to display the correct answer and 3 incorrect answers in a random order from which the user can choose. I can display four possible answers randomly as below.....
// Retrieve all the data from the table $result2 = mysql_query("SELECT Item_1,Item_2,Item_3,Item_4,Item_5,Item_6 FROM kanji.sentence WHERE sentence = $row[sentence] ORDER BY RAND() LIMIT 0,4") // store the record of the table into $row $row2 = mysql_fetch_array( $result );
...of course the above doesn't always return the correct answer (Item_1) with another 3 possible answers, it just returns a random 4 answers. How can I always return 'Item_1' plus any 3 of the remaining Items (Item_2, Item_3, Item_4, Item_5, Item_6) in a random order?