june_c21 Posted March 30, 2010 Share Posted March 30, 2010 Hi , I got a question . How to stop enter the data into database when the $causes == NULL ? Here is my code <?php include './includes/header.php'; for ($i=1;$i<11;$i++) { $id = $_GET ['id']; $causes = $_POST ['causes'][$i]; $corrective_action = $_POST ['corrective_action'][$i]; $name = $_POST ['name'][$i]; $date = $_POST ['date'][$i]; $completedate = $_POST ['completedate'][$i]; $remarks = $_POST ['remarks'][$i]; $status = $_POST ['status']; $query= "INSERT INTO corrective_action( id, causes, corrective_action, name, date, completedate, remarks ) VALUES ('$id','$causes','$corrective_action','$name','$date','$completedate','$remarks') "; $result = mysql_query($query,$dblink); } $query1= "UPDATE event SET status= '$status' where id=$id "; $result1 = mysql_query($query1,$dblink); ?> Link to comment https://forums.phpfreaks.com/topic/196934-help-with-null/ Share on other sites More sharing options...
slurpee Posted March 30, 2010 Share Posted March 30, 2010 if(is_null($causes)) break; Or, if you want the loop to continue even if $causes is null, use this: if(is_null($causes)) continue; Link to comment https://forums.phpfreaks.com/topic/196934-help-with-null/#findComment-1033893 Share on other sites More sharing options...
june_c21 Posted March 30, 2010 Author Share Posted March 30, 2010 TQVM Link to comment https://forums.phpfreaks.com/topic/196934-help-with-null/#findComment-1033897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.