我正在为我们的清洁服务公司建立一个php程序,我们每天发送两次清洁工,我想限制条目。如果清洁剂在下一个条目中插入两次,则应该给出此消息"此清洁剂已完全预订"。我正在使用日历类型的预订。 我的插入代码是:
$query = "INSERT INTO bookings ( uid, empname, date, custname, cleaner, address) VALUES ('$uid', '$empname', '00:00:00', '$_post[custname]', '$_post[cleaner]', '$_post[address]')";
$result = mysql_query($query);
答案 0 :(得分:0)
您只需在特定日期检查清洁工的旧记录。使用以下脚本获取具有日期的旧记录:
$prevRecordsQuery= "SELECT COUNT(*) AS records FROM `bookings` WHERE `date` = $date AND `cleaner` = '$_post[cleaner]'";
$prevRecords = mysql_query($query);
if($prevRecords)
echo "This cleaner is fully booked";
else{
$query = "INSERT INTO bookings ( uid, empname, date, custname, cleaner, address) VALUES ('$uid', '$empname', '00:00:00', '$_post[custname]', '$_post[cleaner]', '$_post[address]')";
$result = mysql_query($query);
}