Jump to content

Array problem


murfitUK
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...