Page 1 of 1

Update all records with this "field"[Topic Solved]

Posted: Sun Oct 14, 2007 3:22 pm
by SirChick
Is there a way to make a script that does this:

Find all records with $Currentstat less than $Max...

Then with all records found with that... add X amount on to "Current field" ?

But this script needs to run on its own as i will be using it as a Cron so even if no one is logged in it should still work.
And if $CurrentStat is equal to Max then do nothing?

Posted: Sun Oct 14, 2007 3:28 pm
by Christopher

Code: Select all

$sql = "UPDATE mytable SET Current_field=Current_field+$X WHERE Currentstat<$Max";

Posted: Sun Oct 14, 2007 5:14 pm
by SirChick
Thank but there is one problem.

$Max is in the database.... how would it check every user's $Max (as they are all different per user) ?

Posted: Sun Oct 14, 2007 5:16 pm
by RobertGonzalez
Replace $Max with the fieldname that contains $Max.

Posted: Sun Oct 14, 2007 5:17 pm
by SirChick
thankyou