;

PDA

Click to See Complete Forum and Search --> : Display Available Times vs selected time


launchpad67
04-16-2007, 03:04 PM
I'm working on another reservation system and I would like to display the "available times" if the time the user has picked is Not available. (Like an airline reservation system)

I have a query that works fine for determining if the time is full but I would like to show the available times for that given date.

Here's my current query:

$sql = " SELECT * FROM `yppentries` WHERE `time` = '$time' AND `resdate` = '$resdate' ";
$result = mysql_query($sql) or die("<font color='#000000'>Query failed: $sql - " . mysql_error());
$entries = mysql_num_rows($result);
if ($entries <=1) {
echo "<center><font color=green size=4><b>&gt; $_POST[time] is Available on $_POST[month]-$_POST[day]-$_POST[year] !! &lt;</b>";
} else {
echo "<center><font color='#ff0000'><b>Sorry, but the Time on $resdate you selected is not available!<br />Please pick another time and try again<br />";
##### Query to find what times Are available for the selected date #####
### Insert next Query here ###

}

The times available for any date are: 11:00, 11:30, 2:00, 2:30, 5:00, 5:30
Each time is available twice per day. Meaning there are 2 - 11:00 slots and 2 - 11:30 slots, ect...

So, I need to subtract the selected time from all the available times and run a new query to display the results within the last else echo statement.

I could probably make another db table and setup reference rows but I think I can do this with just another query instead.

Thanks for any help,

fasco1
04-16-2007, 10:58 PM
I'm working on another reservation system and I would like to display the "available times" if the time the user has picked is Not available. (Like an airline reservation system)

I have a query that works fine for determining if the time is full but I would like to show the available times for that given date.

Here's my current query:

$sql = " SELECT * FROM `yppentries` WHERE `time` = '$time' AND `resdate` = '$resdate' ";
$result = mysql_query($sql) or die("<font color='#000000'>Query failed: $sql - " . mysql_error());
$entries = mysql_num_rows($result);
if ($entries <=1) {
echo "<center><font color=green size=4><b>&gt; $_POST[time] is Available on $_POST[month]-$_POST[day]-$_POST[year] !! &lt;</b>";
} else {
echo "<center><font color='#ff0000'><b>Sorry, but the Time on $resdate you selected is not available!<br />Please pick another time and try again<br />";
##### Query to find what times Are available for the selected date #####
### Insert next Query here ###

}

The times available for any date are: 11:00, 11:30, 2:00, 2:30, 5:00, 5:30
Each time is available twice per day. Meaning there are 2 - 11:00 slots and 2 - 11:30 slots, ect...

So, I need to subtract the selected time from all the available times and run a new query to display the results within the last else echo statement.

I could probably make another db table and setup reference rows but I think I can do this with just another query instead.

Thanks for any help,


if ($entries <=1) Wouldnt' this statement alone allow 2 entries

fasco1
04-16-2007, 11:07 PM
I'm looking into the coding involved to allow days and times to be visually shown open or taken. Like an appointment book so viewers can see at a glance what time slots are open and select them. If anyone can point me in the right direction I would appreciate it.

launchpad67
04-17-2007, 02:58 AM
if ($entries <=1) Wouldnt' this statement alone allow 2 entries
Yes, that's what I said in my post.
"The times available for any date are: 11:00, 11:30, 2:00, 2:30, 5:00, 5:30
Each time is available twice per day. Meaning there are 2 - 11:00 slots and 2 - 11:30 slots, ect..."

fasco1
04-17-2007, 11:08 AM
Initially in the second part of your posting it sounded like you were asking how to put in 2 "times" in the dbases

I guess your looking for almost the same type of setup that I am. But I need 10 or so separate booking selections with all different times.

I'm just getting involved in it now, I'm more familiar with flash than PHP if I could get dates to populate into flash for a two week period I may be able to figure out the rest.

I'm figuring having two database fields that would do the main part and of course the name of the person booking the spot, If a person booked a spot by selecting a radio button, flash would send these variables to php then to mysql then disable the radio button and shade it out a little based on the return values.

I havent really had to work with dates before and thats the first thing I would want to set up.

launchpad67
04-21-2007, 07:49 AM
Please.....
I would to keep this thread conductive to the actual topic, thanks.

Anyone have any ideas??