Question 1: Is it possible to feed 1st while loop's output result as 2nd while loop's variable for query?
I have mySQL table "reorder_in_process" below:
(`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');
And my php below:
<?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);
?>
I doesn't work...I want the output result like below:
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
Pls help to find my mistake and solution to it. Thanks.