I have a pretty good idea of how to do this, but I'm not exactly sure... how to do it , if that makes sense. This is still my first day (going on second without sleep) of learning PHP and I'm trying to complete this project before I call it quits. This is actually all that's left before I can call it quits and be happy with myself. So here's the thing.
I know I've asked quite a few questions today, hopefully this is the last one..
Currently my code pulls information from my database and displays it into a table, like so:
Now, this is great for the feature where I want to list the last 15 transactions, which is what my following code does, please excuse anything that's not done efficiently as it's my first day.
<html>
<table border="1">
<tr>
<th>Transaction Date</th>
<th>Transaction Amount</th>
<th>Item Name</th>
<th>Quantity</th>
</tr>
<?php
require_once 'Config.php';
require_once 'Connection.php';
$totalTransactions = 0;
$totalProfit = 0;
$testquery = "SELECT * FROM $tbl_name WHERE DATE($tbl_name.Date)
BETWEEN DATE_SUB(CURDATE(), INTERVAL 15 DAY) AND CURDATE()";
$results = mysql_query($testquery) or die (mysql_error());
while($row = mysql_fetch_array($results))
{
$totalTransactions += 1;
$totalProfit += $row[$ROW_AMOUNT];
echo "<tr>";
echo "<td align='center'>".$row[$ROW_DATE] . "</td>";
echo "<td align='center'>$". number_format($row[$ROW_AMOUNT], 2) . "</td>";
echo "<td align='center'>null</td>";
echo "<td align='center'>null</td>";
echo "<tr>";
}
echo "<tr>";
echo "<td align='center'><strong>SUM:</strong></td>";
echo "<td align='center'><strong>$".number_format($totalProfit, 2)."</strong></td>";
echo "<td align='center'><strong> </strong></td>";
echo "<td align='center'><strong> </strong></td>";
echo "<tr>";
?>
</table>
</html>
Now, I'm trying to figure out how I can group it like such in a table [Day] - [Sum]
I understand how to get the sum for the data, obviously because that's what the script above does for the last 15 transactions, but how about grouping them together?
an example of the output I'm looking for is like this (This was done in pure HTML and is just an example of what I'm trying to achieve)
To re-word my question more efficiently, I'm trying to create another table that shows the sum for each date that there is "Transactions" for.