Hi Me again!
I have just 1 more question. I have this bit of code, besically it looks to see if there is a record in the table, if not it adds one, if there is, it updates it. Only it seems to work the wrong way around. If there are records there, it adds them again, if there arn't it doesn't do anything. Can anyone see anything wrong?
$sql2 = "SELECT * FROM availability WHERE user_id='$sUserID' AND room_code='$sRoomcode' AND start_date='$syear$smonth$sday'";
$result2=mysql_query($sql2);
if ($result2) {
$sql3="INSERT INTO availability (user_id,room_code,status,start_date,end_date) ".
"VALUES ('$sUserID','$sRoomcode','$status','$syear$smonth$sday','$eyear$emonth$eday')";
$result3=mysql_query($sql3);
$feedback .= " Successfully Added All Availability. You Will Receive a Confirmation Email Soon ";
} else {
$sql3="UPDATE availability SET status='$status',end_date='$eyear$emonth$eday'".
"WHERE user_id='$sUserID' AND room_code='$sRoomcode' AND start_date='$syear$smonth$sday'";
$result3=mysql_query($sql3);
$feedback .= " Successfully Updated All Availability. You Will Receive a Confirmation Email Soon ";
}
}
}
I have just 1 more question. I have this bit of code, besically it looks to see if there is a record in the table, if not it adds one, if there is, it updates it. Only it seems to work the wrong way around. If there are records there, it adds them again, if there arn't it doesn't do anything. Can anyone see anything wrong?
$sql2 = "SELECT * FROM availability WHERE user_id='$sUserID' AND room_code='$sRoomcode' AND start_date='$syear$smonth$sday'";
$result2=mysql_query($sql2);
if ($result2) {
$sql3="INSERT INTO availability (user_id,room_code,status,start_date,end_date) ".
"VALUES ('$sUserID','$sRoomcode','$status','$syear$smonth$sday','$eyear$emonth$eday')";
$result3=mysql_query($sql3);
$feedback .= " Successfully Added All Availability. You Will Receive a Confirmation Email Soon ";
} else {
$sql3="UPDATE availability SET status='$status',end_date='$eyear$emonth$eday'".
"WHERE user_id='$sUserID' AND room_code='$sRoomcode' AND start_date='$syear$smonth$sday'";
$result3=mysql_query($sql3);
$feedback .= " Successfully Updated All Availability. You Will Receive a Confirmation Email Soon ";
}
}
}