Hi everyone,
I'm new here, so I might just introduce myself first. I'm Dave, a teacher in Sydney who teaches new arrivals to Australia to speak English.
I have a very simple quiz here (
http://www.tesolclassroom.com/compspelquiz001.html ) which asks students to identify 10 pieces of computer hardware.
I've set up the php code such that each answer is imported directly into a Mysql database (See my code below).
I've got this part working with no problems. Basically each question from 1 to 10 is labelled '$q001' to '$q010', and these correspond with database cells of the same names ( 'q001' to 'q010' ).
However... I also have another cell for each question which is the same name, but with 'score' appended to the end ( ie: 'q001score' to 'q010score' ).
Is it possible to send a value of '1' to each of these score cells if the student spells the piece of hardware correctly, or a value of '0' to each of these score cells if the word is not spelt this way?
Ie: The first answer is a 'mouse'. If the student spells it correctly (case sensitive), I'd like the value '1' sent to cell q001score, and if they spell it any other way (or leave it blank), a '0' would be sent to this cell? Similarly, the second answer is 'monitor', and I'd like a '1' sent to cell q002score if it is spelt as such, or a '0' sent to this cell if it is spelt any other way.
The second part of my question relates to adding these scores. The final cell in my Mysql database is entitled 'totalscore'. Is it possible to add the numbers from cells '001score' to '010score' to put a total in this final cell?
Thanks for your time,
Dave
$query = "INSERT INTO compspelquiz001 (firstname, lastname, class, q001, q002, q003, q004, q005, q006, q007, q008, q009, q010)" . "VALUES ('$firstname', '$lastname', '$class', '$q001', '$q002', '$q003', '$q004', '$q005', '$q006', '$q007', '$q008', '$q009', '$q010')";
//if($query){echo 'data has been placed'}
mysql_query($query) or die(mysql_error());
mysql_close($con);