tobyw_1969
11-24-2003, 08:56 AM
I am trying to use PHP to keep the results of a quiz in a database. I want to be able to record the total number of players, the total score, and the distribution of the scores from 1-20.
I want to do this with one entry in a database with columns for each of the possible scores like this
total_players, total_score, 1, 2, 3, 4, 5, 6, 7, 8, ..etc
Then I am trying to update the relevant column each time the quiz is completed.
The problem I am having is trying to access the columns 1-20. I don't know how to use a variable to retrieve and set the contents of a column. So far I am doing this
$score = $_REQUEST["score"];
$query = "select * from naaas where country = '".$country."'";
$result = mysql_query($query);
$row=mysql_fetch_array($result);
$oldtotal = stripslashes($row['total_players']);
$oldtotalscore = stripslashes($row['total_score']);
$oldspecificscore = stripslashes($row['.$score']"
This correctly retrieves the current score and total players, but I don't know how to do the 3rd one. For example, can I strip out the column labelled '2' using a variable with a value of '2' - and if so what should be the syntax?
Many thanks for any help you can give.
Toby
I want to do this with one entry in a database with columns for each of the possible scores like this
total_players, total_score, 1, 2, 3, 4, 5, 6, 7, 8, ..etc
Then I am trying to update the relevant column each time the quiz is completed.
The problem I am having is trying to access the columns 1-20. I don't know how to use a variable to retrieve and set the contents of a column. So far I am doing this
$score = $_REQUEST["score"];
$query = "select * from naaas where country = '".$country."'";
$result = mysql_query($query);
$row=mysql_fetch_array($result);
$oldtotal = stripslashes($row['total_players']);
$oldtotalscore = stripslashes($row['total_score']);
$oldspecificscore = stripslashes($row['.$score']"
This correctly retrieves the current score and total players, but I don't know how to do the 3rd one. For example, can I strip out the column labelled '2' using a variable with a value of '2' - and if so what should be the syntax?
Many thanks for any help you can give.
Toby