This is my current code...
function add_date($sUserID,$sRoomcode,$sday,$smonth,$syear,$eday,$emonth,$eyear) {
global $feedback;
//all vars present?
if ($sUserID && $sRoomcode && $sday && $smonth && $syear && $eday && $emonth && $eyear) {
$sql="INSERT INTO availability (user_id,room_code,start_date,end_date) ".
"VALUES ('$sUserID','$sRoomcode','$sday$smonth$syear','$eday$emonth$eyear')";
$result=db_query($sql);
if (!$result) {
$feedback .= ' ERROR - '.db_error();
return false;
} else {
$feedback .= ' Successfully Added Availability. You Will Receive a Confirmation Email Soon ';
return true;
}
} else {
$feedback .= ' ERROR - Must Fill In All Required Fields ';
return false;
}
}
Which just adds a new record, I'd like to be able to search for existing record, and update it, using something like..
$sql="SELECT * FROM availability WHERE user_id='$sUserID' AND room_code='$roomcode' AND start_date='$sday$smonth$syear'";
$result=db_query($sql);
if (!$result || db_numrows($result) > 1) {
$sql2="UPDATE availability SET start_date='$sday$smonth$syear' WHERE user_id='$sUserID'";
$result=db_query($sql2);
if (!$result) {
$feedback .= ' Record Updated ';
return true;
I've tried adding this codes together, but its returing parse errors, and I'm not sure why!
/voodoo