query("SELECT * FROM projects where year=2014"); $c = 0; while($d = $q->fetch_assoc()) { $p = project_load($mysqli, -1, $d); $q1 =$mysqli->query("SELECT * FROM users WHERE s_accepted=0 AND s_pid='{$p['pid']}'"); if($q1->num_rows == 0) { $q1 = $mysqli->query("UPDATE projects SET accepted=1 WHERE pid='{$p['pid']}'"); $c++; } } print("Set $c projects to accepted\n"); ?>