[英]How do i fill values into table, which are got from mysql database using PHP?
Problem Statement: Fill the time values into table with respect to dates using PHP, MySQL and HTML. 问题陈述:使用PHP,MySQL和HTML将时间值填入表格中。
Overview: Developing a web application to manage time-sheet of employees, 概述:开发Web应用程序来管理员工的时间表,
Lets say user fills and submits the time-sheet on Monday, and logs in on Tuesday to web app, when user selects the date and click on 'SubmitDate' button all the previous date values ( Monday's) should get filled and should get freezes ( non-editable). 假设用户填写并在周一提交时间表,并在星期二登录到Web应用程序,当用户选择日期并单击“SubmitDate”按钮时,所有以前的日期值(星期一)应该被填满并且应该冻结(不可编辑)。
Code(for table logic) 代码(用于表逻辑)
Tasks Monday Tuesday Wednesday Thursday Friday Saturday Sunday 任务周一周二周三周四周五周六周日
<tr> <th>DATES</th> <?php //while ($a <7):?> <th> <?php //$output = getStartAndEndDate(2, 2015); echo $output?> </th> <?php //$a++; ?> <?php //endwhile ?> </tr> <?php $sdate = $_SESSION['start_date1'];?> <?php $parts = explode('-', $sdate);?> <tr> <th>DATES</th> <?php $year=$parts[0]?> <?php $time = strtotime("$parts[2].$parts[1].$year", time());?> <?php $day = date('w', $time); ?> <?php $time += ((7*$week)+1-$day)*24*3600;?> <?php $return[0] = date('Yn-j', $time);?> <th> <?php echo "$return[0] <br>"; ?> </th> <?php $m = 0;?> <?php while ($m<6):?> <?php $i=1; ?> <!-- <?php $time// += ((7*$week)+1-$day)*24*3600;?> --> <?php $time += $i*24*3600; ?> <?php $return[1] = date('Yn-j', $time); ?> <!-- <?php //echo "$return[1] <br>"; ?> --> <th> <?php echo "$return[1] <br>"; ?> </th> <?php $m++; ?> <?php endwhile ?> </thead> <?php foreach ($separateTaskList as $val1):?> <tr> <th> <?php echo $val1?></th> <td contenteditable="true"> 0</td> <td contenteditable="true"> 0</td> <td contenteditable="true"> 0</td> <td contenteditable="true"> 0</td> <td contenteditable="true"> 0</td> <td contenteditable="true"> 0</td> <td contenteditable="true"> 0</td> </tr> <?php endforeach; ?> </tbody> </table> <div class="container" style="text-align:center"> <button style="" onclick="actionSend()" class="btn-default-submit submitbtn" align="center">SUBMIT</button></div>
Code( to push values to db): 代码(将值推送到db):
$stmt = $dbh->prepare("INSERT INTO timesheet_details
(emp_id, tmsheet_week_start_dt, tmsheet_activity_dt, project_id, task_id,
activity_tm_spent_min, tmsheet_status, tmsheet_submit_dt, tmsheet_approve_dt, tmsheet_approver_id )
VALUES
($emp_id, '$tmsheet_week_start_dt', '$tmsheet_week_start_dt', '$project_id', '$task_id' , $_totalMinutes, 'Notapproved', '$tmsheet_week_start_dt', '$tmsheet_week_start_dt', 1000 );");
$stmt->execute();
Question: How do i retrieve the data and fill on the same table according to date? 问题:如何根据日期检索数据并填写同一个表?
I am happy to any missing detail if any. 如果有任何遗漏,我很高兴。 Help would be appreciated.
帮助将不胜感激。
After you use the following code 使用以下代码后
$stmt = $dbh->prepare("INSERT INTO timesheet_details
(emp_id, tmsheet_week_start_dt, tmsheet_activity_dt, project_id, task_id,
activity_tm_spent_min, tmsheet_status, tmsheet_submit_dt, tmsheet_approve_dt, tmsheet_approver_id )
VALUES
($emp_id, '$tmsheet_week_start_dt', '$tmsheet_week_start_dt', '$project_id', '$task_id' , $_totalMinutes, 'Notapproved', '$tmsheet_week_start_dt', '$tmsheet_week_start_dt', 1000 );");
$stmt->execute();
Try and do a fetch all which you can retrieve into the fields. 尝试并将所有可以检索的内容提取到字段中。 For example do a fetch all and grab the values from the database .
例如,执行全部获取并从数据库中获取值。
Example: 例:
$stmt = $dbh->prepare("Select * FROM timesheet_details WHERE emp_id = $emp_id");
$stmt->execute
Then in HTML just get the echo the different days. 然后在HTML中获取不同日期的回声。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.