|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Listing dates as Sept 2-4,7-9 & Oct 4,5,6 etc.
Hello! I'm a newbie to dates in php and MySQL, and I have spent hours looking through forums for an answer to what I'm trying to do... I've found plenty on displaying single dates and comparing two dates, for example, but nothing on listing many dates...
Sorry if it's overkill, but I'll explain what I'm trying to do so the real coders (I'm a cut-and-paste developer right now with no real skills) can point me in the right direction properly... I've build a form to input lots of dates into a MySQL table. Specifically, I've got two kinds of dates: multi-day events (where I have a startdate and enddate) and single-day events. Each entry (row) in the table has up to 10 such start- and end-dates and 30 single-day event dates. The dates are of the 'date' type, such that they are MM-DD-YYYY in the db. As an example, consider I want to list three multi-day events and two single days after each of multi-day events. I don't want to have the month displayed again and again, just once for each set of dates... I'm trying to display the multi-day events as: Sept 22-28 / Oct. 2-8 and 14-18 for example And display the single-day events as: Sept. 29 / Oct. 1,9,10,19 and 20 for example Any help you can give would be very appreciated! |
|
#2
|
|||
|
|||
|
Welll without thinking about the problem too much, there's one obvious tip I can give you...
Break it down. Don't try to put too much info into 1 row. After all, you can add as many rows/fields as you need. For Instance: Say you had three events that occured on several different dates. Event 1 - September 1-3; October 1-3; November 1-3 Event 2 - January 1 Event 3 - February 14-15; July 23 Create different rows for each month/event: Row 1 - event=event_1, month=september, dates=1.2.3 Row 2 - event=event_1, month=october, dates=1.2.3 Row 3 - event=event_1, month=november, dates=1.2.3 Row 4 - event=event_2, month=january, dates=1 Row 5 - event=event_3, month=february, dates=14.15 Row 6 - event=event_3, month=july, dates=23 I know this isn't code you can copy/paste, but then again I'm not charging you either. This is just a helpful hint. It will be easier to code the above scenario then it would be to write a function to determine different months, different dates, consequtive dates, non-consequtive dates, single dates, multiple dates. Especially since you're trying to store all of the above in one row. Breaking it down will make it easier to read and easier to code. |
|
#3
|
|||
|
|||
|
Dates in php
sorry, but that's theoretically helpful, but otherwise not. I need some code. I can't seem to make anything I find work for me. And reading the PHP manual or MySQL is worse than Greek. Can someone point me to a good resource on PHP dates? If I find any, I'll come back and post them here, but so far nothing I've found is well-documented enough to make work. Thanks.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Listing dates as Sept 2-4,7-9 & Oct 4,5,6 etc. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|