I have a table called that's value is the $instructor
:
ID | start_date_time | end_date_time |
---|---|---|
1 | 2018-04-01 10:00:00 | 2018-04-02 14:00:00 |
The user in imputing a desired start and end date&time through a from to create a new event. I am seeking to check for any conflicting events via a mysqli_num_rows
with a SELECT query as such :
$sql = "SELECT * FROM `$instructor` WHERE ('$FromDateTime' between start_date_time and end_date_time) OR ('$ToDateTime' between start_date_time and end_date_time) LIMIT 1";
$query = mysqli_query($db_conx4, $sql);
$instructorcheck = mysqli_num_rows($query);
I would then later on call the number of rows during an if() statement :
if ($instructorcheck > 0 || !$instructorcheck){....
I'm not sure if my formatting is incorrect but I keep on receiving a : mysqli_num_rows() expects parameter 1 to be mysqli_result
error.
I'm not sure my statement is correct because what if a user requests and event with the start and end date&time being outside the existing events such as here : from 2018-04-01 09:00:00 to 2018-04-02 15:00:00... Then neither the start or end times will fall between
the start_date_time and end_date_time in the table and the number of rows returned would be zero I presume... ?