|
Posted by zach on 07/22/07 05:46
Hi,
I'm struggling to figure something out. What I have are thousands of
questions from 5 books of the bible in a database. The questions are
labeled with the book name, chapter, verse and type of question as
follows: X, B, G, A, M, R. I need to be able to select 11 questions of
the G type, 5 of A, 1 M, 1 R, 1 X, AND 1 B. I need to select them all
randomly and display them randomly. I want to give user the option to
change the range of books and chapter from which the questions are drawn
from and the number of each type they want.
I have this mysql code:
"SELECT * FROM questions WHERE book IN ('Galatians',
'Ephesians','Philippians') AND chapters IN ('G1', 'G2', 'G3', 'E1',
'E5', 'P1') type='G' ORDER BY RAND() LIMIT 11)"
This selects all the general questions (type g) the three books and
their chapters and then randomizes them and selects the 11 I need of
type G.
I can run this query six times, one for each type but I'm still not
displaying them to the user in random order. In other words with a while
loop and mysql_fetch_array() I get 11 general questions followed by 5 of
A type and so on. How can take the six queries, and put them all into
an array that can be randomized and still keep the array key/value pair
as taken from the database.
I have a sample form of what options I want to give the user when
generating a set of questions. The only thing you can't find on the form
is that each set (1 page) can have a maximum of 20 questions. The form
can be found at http://athleo.net/sampleForm.php
I hope I haven't confused anyone, any help would be greatly appreciated.
Navigation:
[Reply to this message]
|