Adding of current value to stored value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patsman77
    New Member
    • Nov 2007
    • 27

    Adding of current value to stored value

    Hello All,


    Here's my delimna, I am trying to keep a running total of 1 value while maintaining a weekly value of others...this is what I am trying to do....


    [PHP]//Update/Insert total wins to seperate database
    $sel4="select *from Standings where user_name='$_SE SSION[user_name]'";
    $result4=mysql_ query($sel4);

    $num4 = mysql_num_rows( $result4);
    if ($num4 != 0)
    {
    $up="UPDATE Standings set user_name='$row[user_name]', Winner='$Winner ', Losses='$Losses ', Ties='$Ties', TotalWins='$Tot alWIns' + '$Winner' where user_name='$row[user_name]'";
    if (!mysql_query($ up))
    {
    die('Error: ' . mysql_error());
    }

    }
    else
    {

    $sql4="INSERT INTO Standings ( user_name, Winner, Losses, Ties, TotalWins)
    VALUES
    ('$row[user_name]','$Winnner','$ Losses','$Ties' ,'$TotalWins' + '$Winner')";
    if (!mysql_query($ sql4))
    {
    die('Error: ' . mysql_error());
    }
    {
    echo "$Winner";
    }
    }
    } [/PHP]

    I am trying to insert/update $Winner(wins for the week), $Losses(Losses for the week), $Ties(ties for the Week) and then Total Wins as a total where it recalls the Total Wins stored from previous week and adds it to the current week wins.

    What I get stores is is correct for the Wins, Losses, Ties, but the Total Wins keeps coming up as Wins...and not a "running total"... anyone see where I am going wrong?

    Any help would be great,

    Patsman77
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    I assume your piece of code will never do an update becuase I dont find a COMMIT command after an insert or update statement. Even if you insert in to a table and dont commit, you will lose that data and the insert will happen again for the same user.
    Last edited by debasisdas; Dec 10 '07, 09:24 AM. Reason: removed excess quote

    Comment

    Working...