So I tried making a reservation system for a games library.
$timestamp = (strtotime($StartDate));
$EndDate = strtotime("+$Duration days",$timestamp);
This part of the code converts the date entered into a form into a timestamp The second line of the code calculates the end date timestamp for reserving the game for a certain number of days.
In my mind, how I would do it is by creating a variable and selecting certain values from the database. However, I am not that good at php, so I am not a 100% sure if I am right:
$reserved = mysql_query ("SELECT count(*) FROM reservations WHERE EndDate <= $EndDate AND StartDate >= $timestamp");
if (!$reserved) { /*do nothing*/ } ELSE { echo "That date has already been reserved"; }
What this should do is select the timestamps from the database which clash, and then I can display an error message if the variable $reserved is not empty. However, I can't get it to work. How do I display the error message properly?