2 回答
TA贡献1773条经验 获得超3个赞
我已经更改了 readitems 方法,如下所示,以获得我想要的所需输出。感谢那位试图提供帮助的人。向反对者伸出手指!
public function readitems()
{
$output = '';
$output .='<table id="table8" class="table table-striped table-sm table-bordered">
<thead>
<tr class="text-center">
<th>Sl.No</th>
<th>Order Date</th>
<th>Order No</th>
<th>Waiter Name</th>
<th>Table Name</th>
<th>
<table id="table9" class="table table-striped table-sm table-bordered">
<tr>
<th>Item</th>
<th>Qty</th>
<th>Rate</th>
<th>Total</th>
</tr>
</table>
</th>
<th>Action</th>
</tr>
</thead>
<tbody>';
$count = 0;
$query = "SELECT DISTINCT `orderno`,`orderdate`,`waitername`,`tablename` FROM `entrysales` WHERE `billstatus`='unbilled' ORDER BY `orderno` DESC";
$execute = mysqli_query($this->conn,$query);
while($row3=mysqli_fetch_assoc($execute))
{
echo $orderno = $row3['orderno'];
$count++;
$output .='<tr class="text-center text-secondary">
<td>'.$count.'</td>
<td>'.$row3['orderdate'].'</td>
<td>'.$row3['orderno'].'</td>
<td>'.$row3['waitername'].'</td>
<td>'.$row3['tablename'].'</td>';
$output .='<td><table class="table">';
echo $query1 = "SELECT * FROM `entrysales` WHERE `orderno`='$orderno' ORDER BY id DESC";
$execute1 = mysqli_query($this->conn,$query1);
foreach($execute1 as $row)
{
$output .='<tr class="text-center text-secondary">
<td>'.$row['orderitem'].'</td>
<td>'.$row['orderqty'].'</td>
<td>'.$row['unitprice'].'</td>
<td>'.$row['orderprice'].'</td>
</tr>';
}
$output .='</table></td>';
$output .='<td>
<a href="" title="Edit details" class="text-primary editEntrySalesBtn" id="'.$row3['orderno'].'" data-toggle="modal" data-target="#addTakeOrderModal"><i class="fas fa-edit fa-lg"></i></a>
<a href="" title="Delete details" class="text-danger delEntrySalesBtn" id="'.$row3['orderno'].'"><i class="fas fa-trash-alt fa-lg"></i></a>
</td>
</tr>';
}
$output .='</tbody></table>';
return $output;
}
TA贡献1775条经验 获得超11个赞
public function readitems(){
//$orderno = array();
//$output='';
//$execute1 = array();
echo $query = "SELECT DISTINCT `orderno` FROM `entrysales` WHERE `billstatus`='unbilled' ORDER BY id DESC";
$execute = mysqli_query($this->conn,$query);
while($row=mysqli_fetch_array($execute))
{
//$data1[]=$row;
$orderno = $row['orderno'];
echo $query1 = "SELECT * FROM `entrysales` WHERE `orderno`='$orderno' ORDER BY id DESC";
$execute1 = mysqli_query($this->conn,$query1);
foreach($execute1 as $row1)
{
//echo "Order No:".$row['orderno']." Ordered item is ".$row1['orderitem']."<br>";
echo $row1['orderitem'];
}
//unset($row1);
}
//return $row1;
}
这里回显 $row1['orderitem']; 第二个查询执行良好,并且它根据 orderno 正确显示订购的项目。但是当我调用这个方法时,它在下面的输出中不打印任何内容,即要打印的 php html 代码。当我检查 echo json_encode($execute1); 时 它打印 null 下面的代码有什么问题吗?
$data = $db2->read();
$execute1 = $db2->readitems();
echo json_encode($execute1);
foreach ($data as $row) {
$count++;
$output .='<tr class="text-center text-secondary">
<td>'.$count.'</td>
<td>'.$row['orderdate'].'</td>
<td>'.$row['orderno'].'</td>
<td>'.$row['waitername'].'</td>
<td>'.$row['tablename'].'</td>';
$output .='<td><table class="table">';
$output .= $execute1;
$output .='</table></td>';
$output .='<td>
<a href="" title="Edit details" class="text-primary editEntrySalesBtn" id="'.$row['orderno'].'" data-toggle="modal" data-target="#addTakeOrderModal"><i class="fas fa-edit fa-lg"></i></a>
<a href="" title="Delete details" class="text-danger delEntrySalesBtn" id="'.$row['orderno'].'"><i class="fas fa-trash-alt fa-lg"></i></a>
</td>
</tr>';
}
$output .='</tbody></table>';
echo $output;
- 2 回答
- 0 关注
- 105 浏览
添加回答
举报