$check2 = "SELECT Petition_id,Credit
FROM tb_inc_sub
WHERE
ID = '".$_SESSION["stuid"]."'
AND TermFull = '".$_SESSION["termfull"]."'
AND DayID = '".$rst_choice["DayID"]."' AND (
(TimeIn <= '".$rst_choice["TimeIn"]."' AND TimeEnd >= '".$rst_choice["TimeEnd"]."')
OR
(TimeIn > '".$rst_choice["TimeIn"]."' AND TimeIn < '".$rst_choice["TimeEnd"]."')
OR
(TimeEnd > '".$rst_choice["TimeIn"]."' AND TimeEnd < '".$rst_choice["TimeEnd"]."')
OR
('".$rst_choice["TimeIn"]."' > TimeIn AND '".$rst_choice["TimeIn"]."' < TimeEnd)
OR
('".$rst_choice["TimeEnd"]."' > TimeIn AND '".$rst_choice["TimeEnd"]."' < TimeEnd)
)";
$check2 = <<<SQL
SELECT id, TimeIn, TimeEnd FROM tb_inc_sub
WHERE ID = '$_SESSION[stuid]'
AND Year_School = '$Year_school'
AND dayInWeek = '$dayInWeek'
AND TimeIn <= '$rst_choice[TimeIn]'
AND TimeEnd >= '$rst_choice[TimeEnd]
SQL;