Jump to content

Array problem


murfitUK

Recommended Posts

Maybe there is a way to do this that is so easy I can't see it!Have a database with a table of staff schedules. The table has an ID field, a field to identify the user, a date field and a text field. Each user obviously has a unique ID. If I want to see what William's schedule (user number 12) is for April 2011 I run the querySELECT * FROM `schedule` WHERE `user`=12 AND `date` LIKE '2011-04-%' ORDER BY `date`;Then I can do the usual while ($row = mysql_fetch_array($result)){print substr($row['date'],8,2) . " - " . $row['note'] . "<br />";}which will give me something like04 - Annual Leave05 - Annual Leave14 - Training Course19 - All Day Budget Meeting27 - Out on AppointmentsWhat I would like to do is fill in a diary for the full month so the above example would look something like01 -02 - 03 - 04 - Annual Leave05 - Annual Leave06 - etcI can work out how many days there are in that particular month using the cal_days_in_month function so build the loop $i=1 to 30 etc but I just can't figure out how to use this to get the info from the query $result.Think I am just getting myself confused and can't see the wood for the trees now. All help and/or ideas gratefully received.

Link to comment
Share on other sites

With each iteration, format the expected date string and compare it to the returned date string. If the expected date string is less than the returned date string, print the expected date string. Else, print the returned data as you are currently doing.

Link to comment
Share on other sites

Sounds as though that could be the solution but not sure were I start the iteration? Do I put the for loop inside the while statement or the other way round? I've just got myself so confused with this that I can't think straight now!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...