简体   繁体   中英

How to create dynamically changing table in mysql database based on current timestamp

Hi I have some employee records in MySQL db, and I use PHP to display those records as report. Now I am stuck with some issue, my employee record have future details like whether they are available in a position or not at some point of time. It records details upto 16 weeks ahead of current week. Now I implemented like for each week separate column in the DB, that I created for testing.

Screenshot of my DB - Dates are highlighted using yellow 在此处输入图片说明

But the problem now is I have to manually delete the first date column and add new column at end every week and also I have to update the HTML Form which I used for getting input data.

<form>
                    <table>
                          <tr>
                            <td>Name:</td>
                            <td colspan="5"><input type="text" size="40"/></td>
                          </tr>
                          <tr>
                            <td>Domain: </td>
                            <td><input type="text" size="10"/></td>
                            <td>Project: </td>
                            <td><input type="text" size="20"/></td>
                            <td>Area Of Testing:</td>
                            <td><input type="text" size="20"/></td>
                          </tr>
                          <tr>
                            <td>EmployeeID:</td>
                            <td colspan="2"><input type="text" size="6"/></td>
                            <td>TKID: </td>
                            <td colspan="2"><input type="text" size="7"/></td>
                          </tr>

                          <tr>
                            <td colspan="6">Billability:</td>
                          </tr>
                          <tr>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/29</td>
                            <td><input type="text" size="4"/></td>
                            <td>07/06</td>
                            <td><input type="text" size="4"/></td>
                          </tr>
                          <tr>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                          </tr>
                          <tr>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                          </tr>
                          <tr>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                          </tr>
                          <tr>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/22</td>
                            <td><input type="text" size="4"/></td>
                            <td>06/22</td>
                            <<td><input type="text" size="4"/></td>
                          </tr>

Is their any way to overcome such situation dynamically ? Or Is their any kind of script which will automatically trigger these update on every week ?

Ideally you would have another table with:

EmpID Date Record

Then you would have:

1, "2015-05-01", 3

2, "2015-05-02", 1

etc

Then just add the dates whenever they are inserted, or run a cronjob everyweek to add 7 days to every employee.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM