Jump to content

Array problem


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 post
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 post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...