问题1:while循环的输出结果作为第二个while循环的查询变量吗?PHP第一while循环的输出结果为第二while while循环的查询变量
我有MySQL表下面 “reorder_in_process”:
(`id`, `item`, `to_order`, `cat_no`, `supplier`) VALUES
(48, 'Petri Dish', 62, 1006, 'Progressive'),
(47, 'Beaker', 46, 1005, 'Progressive'),
(46, 'Tissue', 17, 1008, 'Needpoint'),
(45, 'Pipet', 77, 1004, 'Kumpulan');
而且低于我的PHP:
<?PHP
include ('db.php');
$sql4 = "SELECT DISTINCT supplier FROM reorder_in_process";
$result4 = mysqli_query($con,$sql4);
$supplier4 = $row4['supplier'];
$i=0;
while($row4 = mysqli_fetch_array($result4)){
echo "<h4>".$row4['supplier']."</h4>";
echo "<div><table><tr>
<th>No</th>
<th>Item</th>
<th>Cat. No</th>
<th>Buy QTY</th>
<th>Supplier</th>
</tr>";
$sql5 = "SELECT * FROM reorder_in_process WHERE supplier=$supplier4";
$result5 = mysqli_query($con,$sql5);
while($row5 = mysqli_fetch_array($result5)) {
$i++;
echo "<tr>
<td>".$i. "</td>
<td>".$row5['item']."</td>
<td>".$row5['cat_no']."</td>
<td>".$row5['to_order']."</td>
<td>".$row5['supplier']."</td>
</tr>";
}
echo "</table></div>";
}
mysqli_close($con);
?>
我没有工作...我想要的输出结果如下图所示:
Progressive
No Item Cat. No Buy QTY Supplier
1 Petri Dish 1006 62 Progressive
2 Beaker 1005 46 Progressive
Needpoint
No Item Cat. No Buy QTY Supplier
1 Tissue 1008 17 Needpoint
Kumpulan
No Item Cat. No Buy QTY Supplier
1 Pipet 1004 77 Kumpulan
请帮助找到我的错误和解决方案。谢谢。
字符串应该用单引号括起来 “......供应商= '$ supplier4'” – JYoThI
我试图针锋相对...... “供应商= '$ supplier4'”,不工作... –
你需要通过每个供应商更改这样的查询“... supplier ='$ row4 ['supplier']'”@p。 Lau – JYoThI