stangn99 0 Light Poster

Hey guys,
Can anyone provide an example code for something like this:

- I have a bunch of appointments stored in a database.
- appointments have been stored based on user selected Dates
- Users can click "view appointments", which displays a list of ALL appointments made from today till the last appointment.

I want to be able to separate the massive list by MONTH. For example, I want it to look something like this:

[B]MARCH[/B]
04/15/2010   John Smith    1:00-2:00
04/15/2010   John Smith    1:00-2:00
04/15/2010   John Smith    1:00-2:00
04/15/2010   John Smith    1:00-2:00
04/15/2010   John Smith    1:00-2:00
03/15/2010   John Smith    1:00-2:00

[B]APRIL[/B]
03/15/2010   Bob Jones    1:00-2:00
03/15/2010   Bob Jones    1:00-2:00


etc....

I'm currently using a WHILE loop to get all the content from mySQL:

while ($row = mysql_fetch_array($sql)) {
				
$userid=$row['userid'];
$bookdate=$row['bookdate'];
$datebooked=$row['today'];
}

And display the content in a table. If I add the following code:

$displayMonth = strtotime($bookdate);
echo (date("F",$displayMonth));

within the WHILE loop, it will display the results like this:

[B]MARCH[/B]
04/15/2010   John Smith    1:00-2:00
[B]MARCH[/B]
04/15/2010   John Smith    1:00-2:00
[B]MARCH[/B]
04/15/2010   John Smith    1:00-2:00
[B]MARCH[/B]
04/15/2010   John Smith    1:00-2:00
[B]MARCH[/B]
04/15/2010   John Smith    1:00-2:00
[B]MARCH[/B]
03/15/2010   John Smith    1:00-2:00
[B]APRIL[/B]
03/15/2010   Bob Jones    1:00-2:00
[B]APRIL[/B]
03/15/2010   Bob Jones    1:00-2:00


etc....

How can I alter this to display the HEADING MONTH only once?


Thanks for any help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.