prepare("SELECT * FROM schools WHERE year='{$config['FAIRYEAR']}'"); $q->execute(); while($s = $q->fetch(PDO::FETCH_ASSOC) { /* Science head */ if(trim($s['sciencehead']) != '') { $u = db_update_146_handle($s['sciencehead'], $s['scienceheademail'], $s['scienceheadphone'], 'teacher'); if($u != false) { $stmt = $pdo->prepare("UPDATE schools SET sciencehead_uid='{$u['uid']}' WHERE id='{$s['id']}'"); $stmt->execute(); } } /* Now the principal */ if(trim($s['principal']) != '') { $u = db_update_146_handle($s['principal'], $s['schoolemail'], $s['phone'], 'principal'); if($u != false) { $stmt = $pdo->prepare("UPDATE schools SET principal_uid='{$u['uid']}' WHERE id='{$s['id']}'"); $stmt->execute(); } } } } ?>