I have show more detail of my problem, can you help please?

Discussion in 'Databases' started by devo10, Feb 25, 2010.

  1. #1
    Hi

    I have better phrased my question and show you my problem more.

    I’m having this problem. Here is my table:

    username quizid score date pastscore pastdate



    I want my quiz to work like this. After the student takes the quiz for a second time, the score is updated, and the previous score and date are moved to ‘pastscore’ and ‘pastdate’ respectively. Below is the whole code I am using, but it posts ‘score’ and ‘date’ into the database fields when I run the file. I can’t get it to ‘capture’ the actual scores and dates.

    ServerUnion, thanks for your help, but I couldn’t get your recommendation to work. Any ideas?







    <?php


    $username=$_REQUEST["username"];

    $quizid=$_REQUEST["quizid"];

    $score=$_REQUEST["score"];

    $dates=$_REQUEST["dates"];



    $con = mysql_connect("localhost","name","password");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("scores", $con);


    mysql_query("UPDATE scoredate SET score = '$score'
    WHERE username = 'name' AND quizid = 't4'");


    mysql_query("UPDATE scoredate SET date = '$dates'
    WHERE username = 'name' AND quizid = 't4'");



    mysql_query("UPDATE scoredate SET pscore = 'score'
    WHERE username = 'name' AND quizid = 't4'");


    mysql_query("UPDATE scoredate SET pdate = 'date'
    WHERE username = 'name' AND quizid = 't4'");





    mysql_close($con);
    ?>
     
    devo10, Feb 25, 2010 IP