Hi i currently have 5 tables in mysql database. Each table has a set of questions so therefore each table is a section. The programme that I am running allows the table to randomly select 1 question from each section. However I only need 4 questions and I have 5 sections. I want one section to be excluded each time. I would like my code to randomly select 4 sections and take a question from each and echo it out. I would also like it to stop echoing the same question twice. Here is my code:
<?php //Germany Section1 $query="SELECT * FROM Germany order by RAND() LIMIT 1;"; $fetch = mysql_query($query) or die ("Could not find Question"); while ($row = mysql_fetch_assoc($fetch)){ echo $row['Question'].""; } //Britain Section2 $query="SELECT * FROM Britain order by RAND() LIMIT 1;"; $fetch = mysql_query($query) or die ("Could not find Question"); while ($row = mysql_fetch_assoc($fetch)){ echo $row['Question']."
"; } //Russia Section3 $query="SELECT * FROM Russia order by RAND() LIMIT 1;"; $fetch = mysql_query($query) or die ("Could not find Question"); while ($row = mysql_fetch_assoc($fetch)){ echo $row['Question']."
"; } //France Section 4 $query="SELECT * FROM France order by RAND() LIMIT 1;"; $fetch = mysql_query($query) or die ("Could not find Question"); while ($row = mysql_fetch_assoc($fetch)){ echo $row['Question']."
"; } //Italy Section 5 $query="SELECT * FROM Italy order by RAND() LIMIT 1;"; $fetch = mysql_query($query) or die ("Could not find Question"); while ($row = mysql_fetch_assoc($fetch)){ echo $row['Question']."
"; } ?>