473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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='$_SESSION[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='$TotalWIns' + '$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
Dec 10 '07 #1
1 1287
amitpatel66
2,367 Expert 2GB
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.
Dec 10 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Vishal Somaiya | last post by:
Hello I am trying read from a xml file, pull the values in a object and then add the object to an ArrayList. I am using a 'while' loop to move through each node in the xml file and pulling the...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: tshad | last post by:
I have changed my code from a straight string for my Sql to Parameters and can't seem to get it to work. I have the following excerpts from my code: ...
15
by: Jason | last post by:
Currently, I am storing information about the currently logged on user in Session variables that are stored in SQL. However, I am using role-based security, so I am storing custom roles in a...
0
by: Laura K | last post by:
I am working with a shopping cart (I am suing a book). At this point I am trying to add the cartID, the productID, quantity and time. At the same time it is supposed to add a cookie. When I...
4
by: Jon Paal | last post by:
I captured an arraylist into a session value but to display the current values, the page requires a postback or else it displays the prior version of the value. how do I force a post back...
0
by: Mateusz [PEYN] Adamus | last post by:
Hi I have a Typed DataSet. I've databinded it to some text controls on my form, controls show data when I show record. But now I would like to create a new record with this form, controls...
1
damonreid
by: damonreid | last post by:
Access 2003 Microsoft Windows XP Pro Hey, I am currently pulling my hair out here. I have a Form for adding new projects to a database, the only problem is that when I close the form it doesn't...
1
by: sherifffruitfly | last post by:
Hi all, I'm tasked with adding a few fields to our database, and all of the stuff that goes along with it (updating c# UI code, etc.). The database is a few hundred tables, with all of the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.