homepage Welcome to WebmasterWorld Guest from 54.211.95.201
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
IF statement.please help
m8fyu




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

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.

Thanks

 

timster




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

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.

rocknbil




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

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

m8fyu




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

Thanks so much guys. This is perfect.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved