Quote:
Originally posted by superman
i've try to insert and delete record at the same page, but it only can insert and can't delete the record.
when i click submit button from the previous form, the record is insert into table B and delete from the table A.
is the code correct?
<? $Connect = mysql_connect("localhost","root","");
mysql_select_db("mw");
$TodayDate = strftime("%Y-%m-%d");
$TodayTime = strftime("%H:%M:%S");
$result=mysql_query("insert into LeaveApplication1 (StaffID, LeaveType, JobTitle, FromDate, ToDate, Duration, Reason, TodayDate, TodayTime) values ('$StaffID', '$LeaveType', '$JobTitle', '$FromDate', '$ToDate', '$Duration', '$Reason', '$TodayDate')");
$result=mysql_query("delete from LeaveApplication where StaffID='$StaffID' and LeaveType='$LeaveType' and JobTitle='$JobTitle' and FromDate='$FromDate' and ToDate='$FromDate' and Duration='$Duration' and Reason='$Reason' and TodayDate='$TodayDate' and TodayTime='$TodayTime'");
mysql_close();
?>
|
In the first query you have TodayTime, but you don't insert anything into it...
And in the delete query you try to delete where TodayTime='$TodayTime' When mysql's TodayTime is blank...
Just add ... '$Reason', '$TodayDate'
, '$TodayTime')");
to the first query and it will work
