2012-12-07 63 views
0

HTML如何使用今日日曆創建表格? jQuery和PHP

<table class="" id="schedule"> 
     <thead> 
      <tr> 
       <th><input value="Time" type="text"></th> 
       <th><input value="Monday" type="text"></th> 
       <th><input value="Tuesday" type="text"></th> 
       <th><input value="Wednesday" type="text"></th> 
       <th><input value="Thursday" type="text"></th> 
       <th><input value="Friday" type="text"></th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr> 
       <th><input value="9:00am" type="text"></th> 
       <td class=""></td> 
       <td class=""></td> 
       <td class=""></td> 
       <td class=""></td> 
       <td class=""></td> 
      </tr></tbody></table> 

我的問題是,怎樣才能與今天小時動態表,而不必硬編碼在HTML中? 我需要這張表格包括每天每小時(24小時)的tr。

我的目標:我創建一個預訂頁面,我的診所的網站,我必須存儲在MySQL作爲「訪問,name_patient,日期,時間,clinic_num」那個診所的所有訪問,

我取的所有記錄今天從數據庫,我想顯示它在一個表中。

問題

  1. 所以可以有一個人告訴我什麼是最簡單的邏輯流,以產生 這樣的表?

  2. 如何產生今天的小時「9 am,10am,11am」行

注:http://apps.zarjay.net/scheduler/這看起來像我想要什麼,但仍有時間是硬編碼。大多數其他日曆插件是非常複雜的,並在殺死重量我想

etc ? 
+0

1至24循環? – greener

+1

即使您對此進行了硬編碼,我也無法想象24小時以內的所有日期,只需使用JQuery UI就可以實現動態日期輸入 – Dale

+0

。他們已經發明瞭那個輪子。 http://jqueryui.com – PruitIgoe

回答

1

這是爲了做到這一點,我所知道的最簡單的方法:

<table> 
    <?php foreach (range(0, 23) as $i) : ?> 
    <tr> 
     <td><?php echo date('ha', mktime($i, 0)); ?></td> 
     <td>What ever you want here</td> 
    </tr> 
    <?php endforeach; ?> 
</table> 

更改爲range(0,23)的價值觀滿足您的需求

這適用於你的HTML:

<table class="" id="schedule"> 
    <thead> 
     <tr> 
      <th><input value="Time" type="text"></th> 
      <th><input value="Monday" type="text"></th> 
      <th><input value="Tuesday" type="text"></th> 
      <th><input value="Wednesday" type="text"></th> 
      <th><input value="Thursday" type="text"></th> 
      <th><input value="Friday" type="text"></th> 
     </tr> 
    </thead> 
    <tbody> 
     <?php foreach (range(0, 23) as $i) : ?> 
     <tr> 
      <th><input value="<?php echo date('ha', mktime($i, 0)); ?>" type="text" /></th> 
      <td class=""></td> 
      <td class=""></td> 
      <td class=""></td> 
      <td class=""></td> 
      <td class=""></td> 
     </tr> 
     <?php endforeach; ?> 
    </tbody> 
</table>