And I’m gonna tick Rudy off more and suggest a long arsed query; one long arsed in execution, and one long arsed in length.
SELECT productid,quantity,available FROM table;
while($row = mysql_fetch_array($res)) {
if(($row['available'] = 0 && ($row['quantity'] >= 1 || $list[$row['productid']] >= 1)) || ($row['available'] = 1 && $row['quantity'] == 0 && $list[$row['productid']] == 0)) {
$out[] = $row['productid'];
}
}
$string = implode(',',$out);
UPDATE table SET available = available + 1 MOD 2 WHERE productid IN ( $string )