Hey really quick one.
My form creates bookings, but because they are lots of products and can be booked out on the same date.
What i would like is, if there is a booking on that date, return of them, and continue.
Example:
id — date — product
1 — 2011-6-20 — item1
2 — 2011-6-21 — item1
3 — 2011-6-22 — item2
4 — 2011-6-20 — item3
5 — 2011-6-23 — item3
Any thats the same date marked down as once, like id 1 and 4 since they have the same dates, should only do the next stage once.
[code=php]
$bookQuery = mysql_query(“SELECT DAY(Booking_Date) as ‘d’, MONTH(Booking_Date) as ‘m’, YEAR(Booking_Date) as ‘Y’, id, Booking_Name FROM bookings”);
$num_rows = mysql_num_rows($bookQuery);
$i=0;
while ($row = mysql_fetch_array($bookQuery)) {
$d = $row[‘d’];
$m = $row[‘m’];
$Y = $row[‘Y’];
$booking_id = $row[‘id’];
echo ‘{ title: ‘Booking’, start: new Date(‘.$Y.’, ‘.$m.’, ‘.$d.’), url: ‘index.php?function=viewBooking&day=’.$d.’&month=’.$m.’&year=’.$Y.” }’;
if ($i != $num_rows) { echo ‘,’; }
$i++;
}
The output should be the following from the above example:
[code=php]
{ title: ‘Booking’, start: new Date(2011, 06, 20), url: ‘index.php?function=viewBooking&day=20&month=06&year=2011’ },
{ title: ‘Booking’, start: new Date(2011, 06, 21), url: ‘index.php?function=viewBooking&day=21&month=06&year=2011’ },
{ title: ‘Booking’, start: new Date(2011, 06, 22), url: ‘index.php?function=viewBooking&day=22&month=06&year=2011’ },
{ title: ‘Booking’, start: new Date(2011, 06, 23), url: ‘index.php?function=viewBooking&day=22&month=06&year=2011’ }
And as you should see it skipped id 4.
Hope i explained ok, as always thanks for any help! ?