Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

IF statement.please help



9:15 am on Mar 4, 2011 (gmt 0)

5+ Year Member

I'm not sure if this post should go in this forum or the database forum.

I have an events table that include start_date and end_date columns. Both datatypes are DATE and stored in 2011-01-01 format.

I've managed to explode the data and get day, month, year values to use in my html table.

| start | end | name |
| feb 17 | feb 23 | event 1 |
| feb 24 | feb 27 | event 2 |
| feb 28 | mar 03 | event 3 |
| mar 04 | mar 08 | event 4 |
| mar 09 | mar 13 | event 5 |

I'm able to display the data from the table but its just a continual list. I'd like to insert a row (spanning all columns) that displays the month name (whenever the start date is in that particular month).

I've had a look round the net and the forums but can't seem to find a solution. Any advice guys and gals? I'm sure its pretty simple but I just can't seem to fathom it out.



1:37 pm on Mar 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

This is best done in your PHP code that displays the page. It's purely about presentation, so it doesn't belong in the database logic.

Something like this would work:

1 Create varaibles for curent month heading and set to empty string.

2 For each row in the database.

3 Get the row data.

4 If the month selected from the row differs from the current month heading, generate a new month heading, and set the current month heading to the new value.

5 Output the row data.

6 Proceed to next row in database.


5:00 pm on Mar 4, 2011 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

That's how I'd do it, see my post here [webmasterworld.com] for an example.


4:33 pm on Mar 5, 2011 (gmt 0)

5+ Year Member

Thanks so much guys. This is perfect.

Featured Threads

Hot Threads This Week

Hot Threads This Month