Insert into mysql condition checkbox
Posted: Thu Jan 08, 2009 4:20 am
Hello I have the following code which insert values into two mysql tables "projects" and "project_comments"
I have a conditional checkbox on my input form that when unchecked I want it to not insert the second query "$sql1" so I created an "If" condition (Below)
However when I uncheck the box I get a "Query was empty" error via
If I leave the box checked both queries operate successfully which is correct
Can anyone see any claring errors?
Thanks
Geoff
Code: Select all
$sql="update projects set VSI_NUMBER='$VSI_NUMBER',Salesman='$Salesman',ENGINEER ='$ENGINEER',Prod_Spec ='$Prod_Spec'
,CUSTOMER ='$CUSTOMER',SALESGROUP ='$SALESGROUP',SICCODE ='$SICCODE',Conf_fact ='$Conf_Fact',N_E ='$N_E'
,YEARQTY ='$YEARQTY',CHCKLRATIO ='$CHCKLRATIO',VALUEExworks ='$VALUEExworks',COMPET ='$COMPET', DATEIN ='$DATEIN'
,COMMENTS ='$COMMENTS',ACTIONDATE ='$ACTIONDATE',Project_Members ='$Project_Members'
,Gate ='$Gate',Job_No ='$Job_No',Cata_Number ='$Cata_Number',orderrec ='$orderrec',Produced_at ='$Produced_at'
,Status ='$Status',Suspend ='$Suspend',product = '$Product',Comm_Memb ='$Comm_Memb',ECR_NUMB = '$ECR_NUMB' where VSI_NUMBER='$VSI_NUMBER'";
$sql1="insert into project_comments(ID,Comments,ActDate,Proj_Member)
Code: Select all
$sql="update $branch set VSI_NUMBER='$VSI_NUMBER',Salesman='$Salesman',ENGINEER ='$ENGINEER',Prod_Spec ='$Prod_Spec'
,CUSTOMER ='$CUSTOMER',SALESGROUP ='$SALESGROUP',SICCODE ='$SICCODE',Conf_fact ='$Conf_Fact',N_E ='$N_E'
,YEARQTY ='$YEARQTY',CHCKLRATIO ='$CHCKLRATIO',VALUEExworks ='$VALUEExworks',COMPET ='$COMPET', DATEIN ='$DATEIN'
,COMMENTS ='$COMMENTS',ACTIONDATE ='$ACTIONDATE',Project_Members ='$Project_Members'
,Gate ='$Gate',Job_No ='$Job_No',Cata_Number ='$Cata_Number',orderrec ='$orderrec',Produced_at ='$Produced_at'
,Status ='$Status',Suspend ='$Suspend',product = '$Product',Comm_Memb ='$Comm_Memb',ECR_NUMB = '$ECR_NUMB' where VSI_NUMBER='$VSI_NUMBER'";
if ( $commupdate == 'on' ) {
$sql1="insert into project_comments(ID,Comments,ActDate,Proj_Member)
values('$VSI_NUMBER','$COMMENTS','$ACTIONDATE','$Comm_Memb')";
}Code: Select all
echo '<pre>sql: '; print_r($sql); echo "\n</pre>\n";
Can anyone see any claring errors?
Thanks
Geoff