I've been trying to code to create the following tables shown in the figure. I need to generate tables for each month but the thing is for 1 month this code generates 3 tables. I only need 1 table for each month. Please if anyone can help me with the code that would be a greate help.
Thanks in advance!
function JobRaised(){
include '../dbc.php';
echo "<br><br>";
echo "<div class='row'><div class='col-sm-6'><h3>Based on Origin</h3>";
$queryt = "SELECT DISTINCT month, Category, Parcels, LoadParcels FROM mDraftProfileLM WHERE month > 202001 ORDER BY month DESC";
$stmt = sqlsrv_query($conn, $queryt);
if ($stmt === false) {
die(print_r(sqlsrv_errors(), true));
}
while ($row1 = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
$month = $row1['month'];
$category = $row1['Category'];
$forecast = $row1['Parcels'];
$actual = $row1['LoadParcels'];
$percentage = $row1['Percentage'];
// Start a new table
echo "<table class='table table-bordered'>
<thead>
<tr class='info'>
<th style='background-color: light blue; color: black;' colspan='5'>" . $month . "</th>
</tr>
<tr>
<th></th>
<th>A</th>
<th>B</th>
<th>C</th>
<th>Total</th>
</tr>
</thead>
<tbody>";
// Add the row for forecast
echo "<tr>
<td>Forecast</td>
<td>" . $forecast . "</td>
<td>" . $forecast . "</td>
<td>" . $forecast . "</td>
<td>" . $forecast . "</td>
</tr>";
// Add the row for actual
echo "<tr>
<td>Actual</td>
<td>" . $actual . "</td>
<td>" . $actual . "</td>
<td>" . $actual . "</td>
<td>" . $actual . "</td>
</tr>";
// Add the row for percentage
echo "<tr>
<td>%</td>
<td>" . $percentage . "</td>
<td>" . $percentage . "</td>
<td>" . $percentage . "</td>
<td>" . $percentage . "</td>
</tr>";
// Close the table
echo "</tbody></table><br>";
}
echo "</div><div class='col-sm-6'></div></div>";
}