Think of it this way. If you have one table which holds reservations, and you have a static number of spots (we'll use 100). Each spot can be reserved in 30 minute increments (as you specified).
Jon reserves spot #83 on August 24, 2009 from 12:00pm until August 31, 2009 at 11:30 am.
Jane reserves spot #84 on August 24, 2009 from 12:00am until August 31, 2009 at 11:00 pm.
Now, say that Dave wants spot #83 (because it's near the pool on the roof of the building). He's planning a trip from August 14 at 8:00 am through August 28 at 11:00 am(a two week window). So Dave comes to your site and says "I want spot #83" and enters his start date and end date into your form.
Your code then takes his start date and looks for any record in your database where someone is already there (e.g. their exit time is > Dave's start time). You'll also need to check to make sure that Dave's exit time doesn't overlap with someone who has already booked a slot for later (e.g. Dave's exit time is > the other persons start time).
Essentially you'd be looking for a query like:
SELECT `id`
FROM `reservations`
WHERE (
(
UNIX_TIMESTAMP('{$daves_start}') < UNIX_TIMESTAMP(`exit`)
)
OR
(
UNIX_TIMESTAMP('{$daves_end}') > UNIX_TIMESTAMP(`start`)
)
)
AND
(
`spot_id` = {$daves_requested_spot}
)
Now, to hopefully make this more clear for you...
Say that Jon reserves spot #15 from December 18 at 4:00 pm until December 30 at 8:30 am. Then Jane comes in and reserves spot #15 from January 6 at 8:00 am until January 20 at 11:00 am.
There is a one week window where spot #15 is open (between December 30 at 8:30 am and January 6 at 8:00 am). Say Dave comes along and is planning a 2-week vacation which spans the new year from December 20 at 12:00 pm until January 3 at 8:00 am.
When Dave goes to check the availability for spot #15, it would be caught because Jon already reserved it until the 30th, and Dave can't overlap his start date with Jon's end date. But Dave could keep his end date since Dave will vacate that spot prior to Jane taking over.
Now, if Dave tries to rework his plans so he leaves on December 30 and decides to want spot #15 on December 30 at 3:00 pm until January 12 at 8:00 am, he would again be stopped because his ending time overlaps with an already scheduled start time (Jane's).
The only way Dave could get that spot over the holiday would be to take it from December 30 at 8:00 am and hold it until sometime before January 6 at 8:00 am.
Hope that makes it clearer.