简体   繁体   English

如何将值填入表中,这是使用PHP从mysql数据库获取的?

[英]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应用程序来管理员工的时间表,

  1. User selects Monday date and all the other week dates gets filled automatically. 用户选择星期一日期,所有其他星期日期自动填写。
  2. User fills his/her time taken for the particular task and submit ( each end of the day s/he does that) 用户填写他/她为特定任务所花费的时间并提交(每天结束时他/她这样做)
  3. 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.

相关问题 使用PHP和MySQL如何使用另一个表中的某些字段值填充一个表 - Using PHP and MySQL how do I populate one table using some field values from another table PHP如何循环从html表单获取的数据并将其保存到mysql数据库中? - PHP how do I loop data which I got from html form and save them into mysql databse? 如何使用 PHP 和 MySQL 更改数据库值? - How do I change the database values using PHP and MySQL? 如何使用php从mySQL表中提取特定值? - How do I extract specific values from a mySQL table using php? 如何用来自MySQL的数据填充PHP数组? - How do I fill a PHP array with data from MySQL? 我如何获得从数据库获取所有值并作为复选框工作的输出的php语句? (PHP / MySQL) - How do I get this php statement that gets all the values from database and outputs as checkboxes to work? (PHP/Mysql) 如何将带有 PHP 的复选框的值传递给 mySQL 数据库? - How do I pass the values of my checkboxes with PHP to mySQL database? 如何使用MySQL和PHP在数据库中的用户之间存储相关值? - How do I store correlation values between users in a database using MySQL and PHP? 如何使用PHP获取MySQL数据库表中的最后一条记录? - How do I fetch the last record in a MySQL database table using PHP? 如何使用php正确显示来自mysql数据库的html标签? - How can I properly show html tags which is come from mysql database using php?
相关标签
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM