Jump to content

[SOLVED] Update all users with certain criteria


SirChick

Recommended Posts

Problem....

I have this script which is to run regardless of who's logged in as its meant to update fields.

The problem i am facing is... users can be a paying member, and so i want to update their field different to the non paying members.

So i need to find a way to check each and every record so that if the field DonatorDaysLeft is greater than 0 then do the first sql in the code below.. else do the other sql

But i don't know how to incorporate such an idea...

 

<?
$connect = mysql_connect("localhost", "root", "nottelling");

//error handle
if (!$connect) {
echo "Unable to connect to DataBase: " . mysql_error();
exit;
}

//error handle
if (!mysql_select_db("civilian")) {
echo "Unable to select table: " . mysql_error();
exit;
}

//something needs to be here
             
If ($DonateDays > 0){
$sql = "UPDATE userregistration SET CurrentEnergy=CurrentEnergy+10 WHERE CurrentEnergy<MaxEnergy";
$sqlresult = mysql_query($sql) or die(mysql_error());
Echo 'Success';
}
Else
{
$sql2 = "UPDATE userregistration SET CurrentEnergy=CurrentEnergy+5 WHERE CurrentEnergy<MaxEnergy";
$sqlresult = mysql_query($sql2) or die(mysql_error());
Echo 'Success2';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.