Ok regarding your comments you can do something like this: Get the events like Davek proposed (note the ORDER BY
!)
$events = mysql_fetch_assoc(mysql_query ("SELECT id,title,date WHERE date BETWEEN '2009-01-01' AND '2009-01-31' ORDER BY date asc"));
Then you got the events ordered by the date. To output it you can do this:
$last_date = null;
foreach($event in $events) {
if($last_date !== $event['date']) {
echo 'Events for day ' . $event['date'] . ": \n";
$last_date = $event['date'];
}
echo $event['title'] . "\n"
}
Note: This is just a rough sketch, you have to adjust the output of course, but it should give you the right idea.
Output would look like this (in my example):
Events for 2009-01-01:
Event 1
Event 2
Events for 2009-01-02:
Event 1
.
.
.
Edit after comment:
You can write your own function:
function get_events($date, $events) {
$result = array();
foreach($event in $events) {
if($event['date'] == $date) {
$result[] = $event;
}
}
return $result;
}
But this way you search the the complete array over and over again for each day. You can improve it, if you remove the events you already searched for from the $events
array. So every time you search in a smaller array. But I would only do this if there is a performance issue.