launchpad67a
11-11-2006, 10:13 AM
Sorry this is a long question it's a bit difficult to explain:
I have a reservation system I have built that has a limited number of entries available per time slot. Two of the input fields are for an 'adult' or 'child'. These fields are text fields where the user simply types the # of adults or child in the box, (ie; adult = 2 child =1). These are stored in the DB as a number under the adult and child columns.
I've setup a query that checks 'availability' for any given time, day, month, year...because there is a limit of "14" for any combination of those entries. That all works fine, but it doesn't check the numbers stored in the adult and child columns (and count them as more than 1 entry).
So here's my problem:
How do I get the query to check the 'adult' and 'child' entries and count them? Because if a user enters 2 adults, this is not being checked in my original query and needs to be counted as '2' entries for that time slot.
I hope this makes sense because it's difficult to explain.
Another example: If a user enters 2 adults, this is still written to a single row in the DB. And only considered as 1 when I do my query to check the availability...when it needs to be counted as "2" entries.
Understand?
Here's the query I'm using to check availability:
$sql = "SELECT * FROM `entries` WHERE `time` = $time AND `day` = $day AND `month` = $month AND `year` = $year";
$result = mysql_query($sql);
$entries = mysql_num_rows($result);
if ($entries < 14) {
Thanks, sorry for the long post.
Mike
I have a reservation system I have built that has a limited number of entries available per time slot. Two of the input fields are for an 'adult' or 'child'. These fields are text fields where the user simply types the # of adults or child in the box, (ie; adult = 2 child =1). These are stored in the DB as a number under the adult and child columns.
I've setup a query that checks 'availability' for any given time, day, month, year...because there is a limit of "14" for any combination of those entries. That all works fine, but it doesn't check the numbers stored in the adult and child columns (and count them as more than 1 entry).
So here's my problem:
How do I get the query to check the 'adult' and 'child' entries and count them? Because if a user enters 2 adults, this is not being checked in my original query and needs to be counted as '2' entries for that time slot.
I hope this makes sense because it's difficult to explain.
Another example: If a user enters 2 adults, this is still written to a single row in the DB. And only considered as 1 when I do my query to check the availability...when it needs to be counted as "2" entries.
Understand?
Here's the query I'm using to check availability:
$sql = "SELECT * FROM `entries` WHERE `time` = $time AND `day` = $day AND `month` = $month AND `year` = $year";
$result = mysql_query($sql);
$entries = mysql_num_rows($result);
if ($entries < 14) {
Thanks, sorry for the long post.
Mike