aeboi80 Posted April 19, 2010 Share Posted April 19, 2010 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 Link to comment https://forums.phpfreaks.com/topic/198968-help-with-while-statement-selecting-all-instances-while-rows-still-exist/ Share on other sites More sharing options...
aeboi80 Posted April 19, 2010 Author Share Posted April 19, 2010 Answered my own question: had the wrong update query. should have been: $query2 = "UPDATE poly_user SET has_hosting='0' WHERE user='$userMMT'"; Link to comment https://forums.phpfreaks.com/topic/198968-help-with-while-statement-selecting-all-instances-while-rows-still-exist/#findComment-1044395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.