I have a html table of 4 rows and four columns and the table is poulated with a random array of 16 out of 20 possibilities. The data is Japanese Kanji characters. I also have little mp3's of the pronounciation of each character and the idea is that the user has to click the table cell that contains the Kanji character they think matches the sound they hear. When they get it correct, they will recieve a score of 1....then they will move onto the next sound out of the original 16, which they will have to match etc etc. When they get sick of this array of 16, they can go back and select a new test, which will repeat the process with a different random array of 16.
What I'm trying to is......Lets assume they get the first one correct.....or incorrect come to that. Now I need to play another sound from the same 16 for the user to match to a table cell. Is it possible to shuffle the array?
// Retrieve all the data from the table $result = mysql_query("SELECT * FROM kanji.temp") or die(mysql_error()); // store the record of the table into $row $row = mysql_fetch_array( $result99 ); srand (); $myarray = array("$row[cpd_id_0]","$row[cpd_id_1]","$row[cpd_id_2]", "$row[cpd_id_3]","$row[cpd_id_4]","$row[cpd_id_5]","$row[cpd_id_6]", "$row[cpd_id_7]","$row[cpd_id_8]","$row[cpd_id_9]","$row[cpd_id_10]", "$row[cpd_id_11]","$row[cpd_id_12]","$row[cpd_id_13]","$row[cpd_id_14]", "$row[cpd_id_15]"); $myarray = $myarray[rand(0,count($doo)-1)]; echo "$myarray";
When the page loads, the result of the echo "$myarray" might be say, 2.mp3 (cpd_id_1). That's great...but...how do I stay in the same page and 'replay' the above, so-to-speak, so that the user can randomly work their way through the entire 16 possibilities? I doesn't matter if, for example, cpd_id_2 gets called twice or even three times as long it is random.
Hope this is possible....or perhaps I'm looking at this wrong. I thought/think shuffle() could be the answer, but I don't know how to stay in the same page and 'shuffle' the array to get a new result. If it is possible, could the array shuffle be triggered by a button perhaps?