I am trying to run a function that will compare a list of answers with the right answers and add points to a variable for right answers and do nothing for wrong answers. It involves two queries of the same table (which is probably inefficient but I don't know what else to do here...).
The problem here is that the result I am getting is only the first row and shows that every answer in that row is correct. Can you spot my error?
Thanks for any help...PHP Code:function scoring()
{
global $valid_user;
if (!($conn = db_connect()))
return false;
$result = mysql_query( "Select * from ep1_picks");
if (!$result)
return false;
$num_results = mysql_num_rows($result);
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
$player = $row["username"];
$result2 = mysql_query( "Select * from ep1_picks where username = '$player'");
if (!$result2)
return false;
$num_results = mysql_num_rows($result2);
//commented this out because there should only be one result per $player
//for ($i=0; $i <$num_results; $i++)
$ep1_score = '0';
$row2 = mysql_fetch_array($result2);
if ($row2["arrive"] = 'Boran'){
$ep1_score = $ep1_score + 40;
} else {
$ep1_score = $ep1_score;
}
if ($row2["jeffname"] = 'Clarence'){
$ep1_score = $ep1_score + 80;
} else {
$ep1_score = $ep1_score;
}
if ($row2["tribefire"] = 'Samburu'){
$ep1_score = $ep1_score + 30;
} else {
$ep1_score = $ep1_score;
}
if ($row2["firstIC"] = 'Samburu'){
$ep1_score = $ep1_score + 50;
} else {
$ep1_score = $ep1_score;
}
if ($row2["firstbootee"] = 'Diane'){
$ep1_score = $ep1_score + 100;
} else {
$ep1_score = $ep1_score;
}
echo $player."<br>";
echo $ep1_score."<br>";
}
}
Cygnus





Bookmarks