现在拔头发
我有一个查询,计算数组中所有相关的 $price 值基本上初始查询检查表中已完成但未开票的作业第二个查询(在初始查询循环内)获取所有需要加起来的项目(这些值在另一个表 (workshop-items) 中找到并根据 $item 数组值进行检查
总数正在计算中,我认为这与 $total 的放置位置有关,因为它加起来了所有返回的总数,而不是单个行的总数
下面的代码
<ul class="list-group">
<?php
$uninvoicedq = mysqli_query($con,"SELECT * FROM `workshop-jobs` WHERE completed = '1' AND invoiced = '0' AND wscid !='0' ORDER BY workstartdate ASC");
$uninvoiced = mysqli_fetch_assoc($uninvoicedq);
if($uninvoiced) {
do {
// User Query
$wscid = $uninvoiced['wscid'];
$userq = mysqli_query($cona,"SELECT * FROM `users` WHERE userid = '$wscid'");
$user = mysqli_fetch_assoc($userq);
$wtbdq = mysqli_query($con,"SELECT * FROM `workshop-jobs` WHERE wsjid = '$uninvoiced[wsjid]'");
$wtbdr = mysqli_fetch_assoc($wtbdq);
do {
$wtbd = explode(":",$wtbdr['worktobedone']);
foreach($wtbd as $item)
{
$priceq = mysqli_query($con,"SELECT * FROM `workshop-items` WHERE wsiid = '$item'");
$pricer = mysqli_fetch_assoc($priceq);
$price[] = $pricer['incvat'];
$items[] = $pricer['description'];
//echo $item.' - '. $pricer['incvat'].'<br>';
}
$total = array_sum($price);
} while($wtbdr = mysqli_fetch_assoc($wtbdq));
?>
<li class="list-group-item text-right" style="border:none;" title="<?php echo $itemview;?>"><span class="badge pull-left" style="background-color:#F00;">Not Invoiced</span><?php echo '£'.$total.' - '; echo $user['forename'].' '.$user['surname'].' - ' .$uninvoiced['summary'];?> </li>
<?
$itemList = implode(":",$items);
$itemview = str_replace(":","\n",$itemList);
?>
<? } while($uninvoiced = mysqli_fetch_assoc($uninvoicedq));
} else {
echo "No Jobs Waiting To Invoiced";
}
?>
</ul>