Iterating through dates in seperate mysql fields $d,$m,$y
Posted: Wed Jun 11, 2008 3:13 am
What I have is a two table in a mysql database. 'listings' with property details
in and 'weeks' which stores the dates in the format dayID, weekID, YearID.
This gives me the start day for when a place will be available.
Upto now I have only needed to do a search on the months before and after the month
being searched but now I need to find out whether the property is actually available
on the date being searched.
I can search on the date values no problem
what I can't get my head around is the best way to iterate through the last 7 days & next 7 days. Should I try to use foreach and store results in a array and then check the array. Has anyone here had to do anything similar?
in and 'weeks' which stores the dates in the format dayID, weekID, YearID.
This gives me the start day for when a place will be available.
Upto now I have only needed to do a search on the months before and after the month
being searched but now I need to find out whether the property is actually available
on the date being searched.
I can search on the date values no problem
Code: Select all
$query1 = "SELECT * FROM listings LEFT JOIN weeks ON weeks.rid = listings.rid WHERE listings.rid = '$rid' AND weeks.dayID = '$day' AND weeks.monthID = '$month' AND weeks.yearID = '$year'";
what I can't get my head around is the best way to iterate through the last 7 days & next 7 days. Should I try to use foreach and store results in a array and then check the array. Has anyone here had to do anything similar?