my db structure looks like this

table "questions"
- questionID
- questiontext
- answer
- class

table "classes"
-class (math, bio, history)

So I have this list with all kinds of questions and i can sort them by class.

Now, I have a form with a list of checkboxes next to each class. The user to selects the classes and specifys the number of questions he would like to see from each class.
0 math [0] questions
x bio [5] questions
x history [2] questions

therefore, my programstructure looks like this:

while($i <= $nrclasses){
$var = "classID$i";
if(isset($$var)) {
$result = mysql_query("SELECT * FROM questions WHERE questions.classID = '$i' LIMIT count");
//---i'm stuck beneath this
while ($temp = mysql_fetch_array($result)){}

So my idea is to go to each class, select a number of questions from that class, and put these in one big php-array.
And that is where i'm stuck.

how can I go through each class, and transfer those questions in one big array?

And how can i access them after that ?

GreetingZ, Highvolt