我似乎无法让我的桌子获得正确的输出。代码如下:
<div class="bubbleTitle">Spetsialistide tööaeg graafiku alusel</div>
<table style="width: 600px" class="slicedTable">
<tr>
<th>Spetsialist</th>
<th>Tunnid</th>
</tr>
<tr>
<?php foreach($specs as $specName => $spec): ?>
<td><?php echo $specName?></td>
<?php foreach($tunnid as $tund): ?>
<td><?php echo $tund?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
我已经尝试了这个线程中的所有内容:表 PHP 中的嵌套循环 ,但这些都不起作用输出如下:
名称 - 值 值
2
值 3
名称
2 - 值 值
2 值
3
等等
我希望它是:
名称 1 - 值1
名称 2 - 值 2 等。
$tunnid
来自哪里 :
result = mysql_query("SELECT `worker_id`, SUM(TIMESTAMPDIFF(HOUR, `start`, `end`)) as `total` FROM
`spa_worker_times` WHERE (`start` BETWEEN '".$validated['start']."' AND '".$validated['end']."') AND
(`end` BETWEEN '".$validated['start']."' AND '".$validated['end']."') GROUP BY `worker_id`") or die(mysql_error());
$tunnid = array();
while ($row = mysql_fetch_assoc($result)) {
$tunnid[] = $row['total'];
规格来自哪里:
$data = $this->BookingProcedures->query("SELECT AProcedure.name, BookingGroup.booking_package_id > 0 AS pack_proc," .
"SUM(BookingProcedure.price) AS price, Worker.name, COUNT(BookingProcedure.id) AS num" .
" FROM spa_booking_procedure_specialists BookingProcedureSpecialist, " .
"spa_booking_procedures BookingProcedure, " .
"spa_booking_groups BookingGroup, spa_procedures AProcedure, spa_workers Worker" .
" WHERE !BookingProcedure.deleted" .
" AND DATE(BookingProcedure.start) >= '".$validated['start']."'" .
" AND DATE(BookingProcedure.start) <= '".$validated['end']."'" .
" AND BookingProcedureSpecialist.booking_procedure_id = BookingProcedure.id" .
" AND Worker.id = BookingProcedureSpecialist.specialist_id" .
" AND BookingGroup.id = BookingProcedure.group_id" .
" AND AProcedure.id = BookingGroup.procedure_id" .
" GROUP BY AProcedure.name, BookingGroup.booking_package_id > 0, Worker.name");