Bottom Line: How to append array values to the HTML Table cell in PHP ?
Detailed Situation: I have an array like this:
Array
(
[PROD-150] => Cancelled
[PROD-80245] => Pending
[PROD-BOOK-65] => Due
)
And I have a HTML table like this:
<tr>
<th>Order Code</th>
<th>Order Date</th>
<th>Customer Code</th>
<th>Customer Name</th>
<th>Products Code</th>
<th>Products Image</th>
<th>Products Name</th>
<th>Product Amount</th>
<th>Commission Percentage</th>
<th>Commission Amount</th>
<th>Order Status</th>
<th>Payment Status</th>
</tr>
Here's the how values are shown in the above table:
foreach ($affiCodeAndAmount as $key => $value) {
$query = "SELECT * FROM products WHERE ProdCode = '".$key."'";
$validate->Query($query);
while ($rows = $validate->FetchAllDatas()) {
foreach ($prdOrdQty as $i) {
$productTotalAmount = $i * $rows["ProdRate"];
}
echo "
<tr>
<td>".$orderCode."</td>
<td>".$orderDate."</td>
<td>".$customerCode."</td>
<td>".$customerName."</td>
<td>".$key."</td>
<td align='center'>
<img src='//placehold.it/50x50'>
</td>
<td>".$rows["ProdName"]."</td>
<td>".$productTotalAmount."</td>
<td>".$rows["ProdAffiCommission"]."</td>
<td>".$value."</td>
<td>".$status."</td>";
foreach($array as $val) {
"<td>".$val."</td>";
}
</tr>";
}
}
When I run the code, the Payment Status Column is like this:
CancelledPendingDue
I want to display the array values in each cell separately with respect to the number of products. It should be like this:
<th>Payment Status</th>
<td>Cancelled</td>
<td>Pending</td>
<td>Due</td>
How do I achieve that ? Kindly help me out. Thanks.
P.S.:: All the values are coming from the database. So the table data can vary accordingly.. It can be any x number.