I am creating an application system. when the applicant applies at the same place/time/day, the system will reject the application.
The same date and time will be rejected but there is a problem in 'day' because the data is combined from the input checkbox. i use sql LIKE for 'day' but not working.
LIKE is only working when the same input is in the database (ex: Rabu= Rabu) working, but (ex: Rabu= Rabu, KHamis, Jumaat) not working even 'Rabu' is in the data.
$checkbox1 = $_POST['day'];
$chk="";
foreach($checkbox1 as $chk1)
{
$chk.= $chk1." ";
}
$sql = "SELECT * FROM job WHERE start <= '$end' and fetchEnd >= '$start' and location = '$lokasi' and timeStart <= '$timeEnd' and timeEnd >= '$timeStart'
and day like '%$chk%' LIMIT 1" ;
$check_query = mysqli_query($con,$sql);
$count_valid = mysqli_num_rows($check_query);
if ($count_valid > 0) {
echo "<script>
alert('Permohonan anda gagal kerana bertindih dengan tarikh / masa / lokasi mesyuarat lain. Sila semak Kalendar Perkhidmatan Sidang Video.');
window.location.href = 'mohon.php';</script>
";
} else {
$sqlInsert = "INSERT INTO job (title,start,end,department,fetchEnd,location,day,timeStart,timeEnd,kekerapan,communication,promoter,typeMeeting,status,employId)
VALUES ('".$title."','".$start."',DATE_ADD('".$end."', INTERVAL 1 DAY),'".$bahagian ."','".$end ."','".$lokasi ."','".$chk ."','".$timeStart ."',
'".$timeEnd ."','".$kekerapan ."','".$komunikasi ."','".$penganjur ."','".$sulit ."','".$status ."','".$id ."')";
$result = mysqli_query($con, $sqlInsert);
}
sorry for my bad english. I hope u guys can help me