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 關注
- 163 瀏覽
添加回答
舉報