Jump to content

display and filter by date


mwjansen

Recommended Posts

i'm in the learning phases of php (i guess maybe we all are, but i'm at phase 1).

 

i've gotten everything i want to do so far - with help from here and the books i've purchased - except for this one.

 

i have a db with items that have dates associated with them. dates are added as needed - there are more than one date for each item in the db.

 

i want to display every item, but only the dates associated with each item based on a filter (ie later than curdate). i'm not sure how to go about this. i'm assuming i need a separate cell for each date. do i then run the query to only display the date fields that fit my criteria? or would i need a separate table for just the dates? so confused - any help is appreciated.

Link to comment
Share on other sites

i guess the question was really a two-parter, the first part being what structure would be best suited for what i'm looking to do?

currently its a simple table with two date fields per row.

i'm not sure that's best way to go about it, as i'd have to filter each date field (there could be as many as twelve/row) individually?

Link to comment
Share on other sites

sorry.

 

i have a number of events, which happen on various dates.

ie event 1 : 12/30/08, 1/15/09, 2/20/09

event2 : 01/02/09, 2/15/09, 3/21/09

etc etc

 

i want every event to display, but within each event, only the dates which meet criteria, ie 30 days from curdate.

 

that make more sense?

Link to comment
Share on other sites

Honestly if it were my DB I would have this table structure,

 

I would have 2 tables

 

event_description

 

event_dates

 

 

event_description:

id:int(16)

title:varchar(255)

description:text()

 

event_dates:

id:int(16)

event_id:int(16)

date:datetime();

 

something like that

 

I would select it like "SELECT event_dates.date as date, event_description.title as title FROM event_dates, event_description WHERE (NOW() - event_dates.date) <= 2592000 AND event_dates.event_id = event_description.id"

 

Something like that

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.