Jump to content

Help uploading results to database


RyanSF07

Recommended Posts

Hi Guys,

 

This code below currently matches a user's answers to a quiz with the answers in the database, then processes them right or wrong.

 

I'd like to be able to keep track of user's answers to the questions, and the results.

 

Along those lines, how can I upload/post these individual results as they are cycled through the While function?

I don't know if I'm asking that correctly -- more or less, is there a way to do something like "This Variable"=all questions, the user's answers, and the results?

 

Please let me know if you have any ideas or suggestions. Thank you!

 

echo "<p>Here are the answers:";

echo "<table border=0 width=100%>";
$display = mysql_query("SELECT * FROM $table WHERE $table.video_id='$_SESSION[get]' ORDER BY id ASC",$db);

while ($row = mysql_fetch_array($display)) {

$question = $row["question"];
$question = stripslashes($question); 
$answer = $row["answer"];
$answer = stripslashes($answer);
$q = $row["q"];
$q = stripslashes($q);
$myanswer = $_POST[$q];
$myanswer = stripslashes($myanswer);


echo "<tr><td><br>$question</td></tr>";

if ($myanswer == $answer) 
	echo "<tr><td>»you answered: $myanswer -- which is correct</td></tr>";
elseif ($myanswer == "")
	echo "<tr><td>»you didn't select an answer. The answer is: $answer</td></tr>";
else
	echo "<tr><td>»you answered: $myanswer. The answer is: $answer</td></tr>";

}

echo "</table></p>";

Link to comment
https://forums.phpfreaks.com/topic/160807-help-uploading-results-to-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.