I need a guiding hand, how do I display the ” current week” starting on Monday , in a 7-day calendar by a 7-room grid, for a small theatre I volunteer at, various voluntary town groups use the rooms.
My database name=rooms, table=roomdiary, it has 7 fields (field_1 to Field_7).
I can populate each day with data from the dbase using the “Select” query & php isset code where required.
But I am stumped on how to correctly display only ” current week ” data in the right room on right day.
>
////// Mon... Tues . Wed .. Thu .. Fri . Sat .. Sun room 1 data . data . data . data . data data . data room 2 data . data . data . data . data data . data room 3 data . data . data . data . data data . data room 4 data . data . data . data . data data . data room 5 data . data . data . data . data data . data room 6 data . data . data . data . data data . data room 7 data . data . data . data . data data . data
I apologise for having not posted any code, as I thought any generic advice would be more than helpful and help me learn. Any guidance would be appreciated.
I recommend you split this problem in two
The first point is quite easy using PHP’s
date()orgetdate()functions, the second can be achieved bySELECT ... WHERE datecolumn BETWEEN monday_date AND sunday_date.This helps modularize your program: What if you want to add future display options? What if your theater decides not to play on mondays?
Additionally I recommend against harcoding your 7 rooms into 7 fields: A relational approach would have a “rooms” table (currently with 7 rows) and a “performances” table linking a room and a date. If you add a “programs” table and also link it to the “performances” table, you already get the program data for free.