2013-01-15 1 views
0

나는 좋은 시간을 Google에서 검색해 왔으며 질문을하는 방식인지 또는 무엇을 찾을 수 있는지는 알 수 없다. 이. 나는 PDO의 SQL 문이 있습니다SQL TimeDiff를 사용하여 PHP 테이블 데이터 채우기

try 
    { 
$query = $dbh->prepare("SELECT id, anum, first, last, signintime, counselorname, 
         finishtime, TIMEDIFF(finishtime, signintime) AS Total_wait FROM inoffice;"); 
$query->execute(); 
$result = $query->fetchall(); 
    } 
     catch (PDOException $e) { 
     error_log($e->getMessage()); 
     die($e->getMessage()); 
     } 

을 한 후 나는 테이블이 같은 구조를 가지고이 땅에서 내가 얻는 방법

<table id='datatables' class='display'> 
       <thead> 
        <tr> 

         <th>Session Id</th> 
         <th>A Number</th> 
         <th>First Name</th> 
         <th>Last Name</th> 
         <th>Signin Time</th> 
         <th>Counselor Name</th> 
         <th>Finish Time</th> 
         <th>Total Wait Time</th> 
        </tr> 
       </thead> 
       <tbody> 
       <?php 
        foreach($result as $row) { 
         ?> 
         <tr> 
          <td><?=$row['id'] ?></td> 
          <td><?=$row['anum'] ?></td> 
          <td><?=$row['first'] ?></td> 
          <td><?=$row['last'] ?></td> 
          <td><?=$row['signintime'] ?></td> 
          <td><?=$row['counselorname'] ?></td> 
          <td><?=$row['finishtime'] ?></td> 
          <td><?= ?></td> 
         </tr> 
<?php 
} 
?>    

        </tbody> 
      </table> 

내 질문에 내 PDO의 마지막 부분은 그 마지막에 선택되어 내 테이블의 td 태그? 내가 혼란스러워하는 부분은 다음과 같습니다 :

TIMEDIFF(finishtime, signintime) AS Total_wait 

나는 그것이 테이블의 마지막 td에 포함되기를 원합니다. 모든 도움/트릭/해결 방법이 좋습니다.

답변

0

당신은 데이터베이스에서 자신의 행으로 TIMEDIFF(finishtime, signintime) AS Total_wait

를 치료해야합니다.

이 결과 :

<td><?=$row['Total_wait'] ?></td> 

이제 테이블이 보이는 좋은 작품 :

enter image description here

관련 문제