dongyan2267 2012-11-27 13:29
浏览 89
已采纳

在7天日历中显示当前周的mysql数据

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.

  • 写回答

2条回答 默认 最新

  • dongluan2612 2012-11-27 13:44
    关注

    I recommend you split this problem in two

    1. Calculate start of display period (="Which date is the current Monday")
    2. Select and display your records

    The first point is quite easy using PHP's date() or getdate() functions, the second can be achieved by SELECT ... 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line