Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Yet Another Calendar Question

Status
Not open for further replies.

roycrom

Programmer
Joined
Aug 2, 2002
Messages
184
Location
GB
I use webalizer to monitor web logs.

All the reports are saved in a date extension, usually there is one for everyday but there are sometimes dates that havn't been monitored for one reason or another.

The date extension gets put into a mysql database as a record of which days have a report page. The date format is YYYYmmdd.

What I want to be able to do is display the dates in a calendar so when you click on the day, it is a link to the relevent report. BUT I also want the absent days greyed out and just text instead of a link. I've looked through the calendar posts on this page and at hotscripts etc.. but can see nothing that would enable me to do this.

Any help or pointers would be greatly appreciated.

------------------------------------------
Somethings come from nothing, nothing seems to come from somethings - SFA - Guerilla

roycrom :)
 
It's not a hard script to write. I'd do it in a table.

I'm assuming that you want to output the standard 7-day-wide, weeks-in-the-month high monthly calendar.

First, I would query for all reports available for a given month and place all that data in an array. The array keys should be the days of the week, the array values the respective reports.

I would pass getdate() ( the date of the first day of the month to be displayed (construct it using string concatenation). getdate() will tell me what day of the week the calendar should start on.

Then output the way-of-week-names row that appears at the top of the row.

I would then initialize a day-of-week counter to 1 and output blank calendar table elements, incrementing the counter for each day square to skip to get the first of the month under the correct day of the week column.

I would then initialize a day-of-the-month counter to 1.

Once I've started outputting the actual days of my month, I would check the report array to see if there is a report for the current day using array_key_exists() ( If there is a report for the day, output the link to it. If there is no report, output a blank square. Either way, increment your day-of-month counter and day-of-week counter.

If at any time the day-of-week counter gets to 7, start a new table row and set the counter back to 1.

Keep doing this until you get to the end of the month.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top