Jump to content

Help with while statement selecting all instances while rows still exist


aeboi80

Recommended Posts

I am trying to query a table where I need to find where all users who are FREE and ACTIVE and has_hosting = 1

and for all records matching this I need to set their value of has_hosting = 0

 

While this is the case execute blah, blah, blah.

 

This is the code I current have

 


$query = "SELECT type, user, status, has_hosting FROM poly_user WHERE type='Free' AND status='Active' AND has_hosting='1' LIMIT 1";	
$result = mysql_query($query);

$number = mysql_num_rows($result);
if(!$number)
            echo "No Records found";
        else
            while ($row1 = mysql_fetch_array($result)) { 
                    // Data is dumped 
				$typeMMT = $row1[0];
				$userMMT = $row1[1];
				$statusMMT = $row1[2];
				$has_hostingMMT = $row1[3];

				$query2 = "UPDATE has_hosting='0' WHERE user='$userMMT'";
				$result2 = mysql_query($query2);
            }  
            

 

but when it runs it never sets the value of has_hosting to a 0

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.