php/sql - basic how to question

Soldato
Joined
6 Mar 2008
Posts
10,080
Location
Stoke area
Hi,

Learning PHP & SQL at the moment and I'm writing a quiz database for our employees to use in their day to day activities.

I've got a form page + a script for entering data in to the table and that works fine, if it's a slow process. Thinking I will enter info in to a spreadsheet and just import it (think that is possible).

The main page is basically 2 text boxes. first is the number of questions they want and the second is the subject they want the questions to be about.

Each question has a main subject (general knowledge etc) and then 4 tags that can be searched. I've figured out how to pull all the questions and print them to the results page.

Next step is to randomly pull X amount of questions and only display those.

Am I better doing this with SQL, ie "pull 10 random questions about football" or would I be better off pulling all the football questions and then using PHP to randomly pull 10 questions from it (if that is possible).

Silly question I know but aren't they always when you start out :p

Will probably end up tidying code as I learn and go, it's a little messy in places. Also need to protect from injection but that will come when its working.
 
thanks for the feedback :)

Yes, I've currently managed to get it running with rand(), but as you say, I'm aware it's slow. Currently only around a few hundred entries but will be looking at several thousand so as my PHP skills progress I can keep updating this :)
 
Back
Top Bottom