Jump to content


Photo

Need help with mysql loop into PHP


  • Please log in to reply
2 replies to this topic

#1 johnska7

johnska7
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 03 May 2006 - 01:23 PM

I'm trying to get a loop going from my mysql database, but I'm running into some logic problems. I think I just need to be shown the road.

What I'm trying to do is display a certain amount of dates, between june 1st of one year and june 1st of the next year, like this:

[img src=\"http://www.sbschools.org/images/chart.gif\" border=\"0\" alt=\"IPB Image\" /]

my database looks like this:

[img src=\"http://www.sbschools.org/images/db.gif\" border=\"0\" alt=\"IPB Image\" /]

So pretty much what I need to do is:

find out what's in the database and sort it into groups of years. For each of the dates returned, I have to find out if it should go into $date[0]-1."-06-01" or $date[0]+1."-06-01" so I can get the listing like in the first picture. Can anyone help me start on this path?

PS - Please ignore the first pictures dates being inconsistent...I just copy and pasted into photoshop

#2 emehrkay

emehrkay
  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 03 May 2006 - 01:29 PM

try
SELECT * FROM table WHERE start_date <= THIS YEAR AND start_date >= LAST YEAR ....

#3 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 03 May 2006 - 05:39 PM

So your year goes from june 1st to May 31st

Ray




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users