i am creating a daily report grouped by the types of product, at the moment this is displayed as a list as below
| Production Date | Egg Type | Total |
|---|---|---|
| 22/01/2023 | Free Range | 22000 |
| 22/01/2023 | Itensive | 10000 |
what i am trying to achieve is to use the eggtype as the headers with the required volume underneath. showing the daily total of all egg_type at the end
| M/S | Free Range | Intensive | Day Total | |
|---|---|---|---|---|
| Monday | 5000 | 5000 | 5000 | 15000 |
| Tuesday | 10000 | 5000 | 12000 | 27000 |
| Wednesday | ||||
| Thursday | ||||
| Friday |
Here is the code i am currently using
<table id="datatable2" name="datese" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<td>Date</td>
<td>Egg Type</td>
<td>Product</td>
<td>Total Kg</td>
</tr>
</thead>
<?php
// Connect to database server
mysql_connect("localhost", "cl30-bumble", "password") or die (mysql_error ());
// Select database
mysql_select_db("cl30-bumble") or die(mysql_error());
$post_at = $_POST["start_date"];
$post_at_to_date = $_POST["end_date"];
$query = "SELECT egg_type, egg_group, total_kg, production_date, SUM(total_kg) FROM order_process WHERE production_date BETWEEN '$post_at' AND '$post_at_to_date' AND product_cat = 'liquid_egg' GROUP BY egg_type, egg_group, production_date ORDER BY FIElD(production_date,'Monday','Tuesday','Wednesday','Thursday','Friday') ";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo '
<tr>
<td>'.$row["production_date"].'</td>
<td>'.$row["egg_type"].'</td>
<td>'.$row["egg_group"].'</td>
<td>'.$row["SUM(total_kg)"].'</td>
</tr>
';
}
mysql_close();
?>
</table>
i now this old version of php as im carrying on from last creator using php5.4 to develope this application .
Any help or guidance would be much appreciated. or if this is even possible.
Thank you
new to php mysql, so been reading through books and or course Google 🙂 cannot find how to do the above