Saving the previous value from mysql query
Posted: Fri Mar 30, 2007 4:55 am
feyd | Please use
In this code, i want the changement that is made on seeded_for from the query to be added to the seed_time. If the code is used like this, seed_time adds the whole seeded_for value to it, not the changement in the seeded_for.
I want to use $dummy to store the previous value of seeded_for (or track) the changement that is made on seeded_for.
Any other ideas to correct this code is more than welcomed, regarding it serves the same purpose
.
Thanks Alot in advance,
Ahmed Ossama
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello All,
How do i save the previous value from mysql, so that i could keep track of its change between the current value and the one i stored?
Here is my codeCode: Select all
$res = mysql_query("SELECT DISTINCT userid, UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(MIN(started)) AS seeded_for, seed_time FROM peers, users WHERE seeder = 'yes' AND userid= " . $CURUSER["id"] . " GROUP BY userid") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0) {
while ($arr = mysql_fetch_assoc($res)) {
if ($arr["seeded_for"] < $arr["seed_time"]) {
$dummy = $arr["seeded_for"]; //I want this variable to be the one that saves the previous value of the seeded_for
mysql_query("UPDATE users SET seed_time = seed_time + $dummy WHERE id IN (SELECT DISTINCT userid FROM peers WHERE seeder = 'yes') = $arr[userid]") or sqlerr(__FILE__, __LINE__);
}
}
}I want to use $dummy to store the previous value of seeded_for (or track) the changement that is made on seeded_for.
Any other ideas to correct this code is more than welcomed, regarding it serves the same purpose
Thanks Alot in advance,
Ahmed Ossama
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]