Hey,
Im creating a calendar, that would show months in a year and inputting the booking in that date slot.
On the booking form the dates are entered in to the MySQL Database as: year-month-day (2010-11-17)
Below gets the month/year from user input, works fine.
[code=php]
function getmicrotime(){
list($usec, $sec) = explode(” “,microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
if (!isset($_GET[‘year’])){
$_GET[‘year’] = date(“Y”);
}
if (!isset($_GET[‘month’])){
$_GET[‘month’] = date(“n”)+1;
}
$month = addslashes($_GET[‘month’] – 1);
$year = addslashes($_GET[‘year’]);
Below here gets the date from the bookings table, and splits up the date, using split() i got this from the PHP manual.
[code=php]
$bookQueryA = mysql_query(“SELECT * FROM bookings”);
while ($row = mysql_fetch_array($bookQueryA))
{
$date = $row[‘Booking_Date’];
list($b_year, $b_month, $b_day) = split(‘[-]’, $date);
}
Now heres where i get stuck, how do i use the WHERE to only grab the bookings thats set by the $month and $year variables.
[code=php]
$bookQueryB = mysql_query (“SELECT * FROM bookings WHERE booking_month=’$month’ AND booking_year=’$year’ ORDER BY Booking_STime”);
while ($row2 = mysql_fetch_array($bookQueryB))
{
$day = $b_day;
$booking_id = $row2[‘id’];
$booking[$day][] = $row2[‘id’];
$booking_info[$booking_id][‘0’] = substr($row2[‘Booking_Name’], 0, 8);;
$booking_info[$booking_id][‘1’] = $row2[‘Booking_STime’];
}
Maybe i have the code an little muddled up, but any help would be highly grateful.
Thanks