我正在 php 中为 mysql 数据库运行一个查询,并成功运行了一个循环来检索我需要的信息。但是,我的部分输出需要一个额外的查询来输出两个字段的时间差异,我无法让它正确回显。$billable 工作正常,只是无法回显附加行以将时差添加到表中
$billable = mysql_query("SELECT * FROM responses WHERE company ='XXXXXX' && date BETWEEN '$start_date' AND '$end_date' && time_arrived >0 && TIMEDIFF(time_arrived, time_received)< 2500", $connection);
$num_rows = mysql_num_rows($billable);
$time_diff = mysql_query("SELECT TIMEDIFF('time_received',time_arrived')FROM alarmresponses WHERE company ='XXXXXXX' && date BETWEEN '$start_date' AND '$end_date' && time_arrived >0 && TIMEDIFF(time_arrived, time_received)< 2500 AS value_sum
", $connection);
$elapsed = mysql_num_rows($time_diff);
while ($bill = mysql_fetch_array($billable)){
echo"<p style='page-break-before: always'>
<table>
<tr><td><p style='text-align: right;'>SCHEDULE B</p></td></tr>
<tr><td><p style='text-align: right;'>Page 1 of 1</p></td></tr>
<tr><td><p style='text-align: center;'>XXXXXXX</p></td></tr>
<tr><td><p style='text-align: center;'>SERVICE RESPONSE REPORT</p></td></tr>
<tr><td>Property Owner's Name</td</td>".$bill['name']."</td><td>DATE</td><td>".$bill['date']."</td></tr>
<tr><td>Address</td><td>".$bill['address']."</td></tr>
<tr><td>Type of SERVICE</td><td>".$bill['type']."</td></tr>
<tr><td>Time Received:</td><td>".$bill['time_received']."</td><td>Time Arrived<td><td>".$bill['time_arrived']."Time Clear:</td><td>".$bill['time_cleared']."</td></tr>";
echo"<tr><td>Total Time Elapsed:"***.$elapsed['value_sum'].***"Minutes00:00</td></tr>";