so i'm making my own financial site for my own purposes, and i use php and mysql. now, i've made a page that groups transactions by category, year and month. and i echo those out. and it works, but i want to break it up by each month, so it's not just a continuous table of data.
any ideas? also, i would like to show a percentage for each each category, but i can only get the percentage of all transactions, and not the percentage of that month.
here is part of the code:
any ideas? also, i would like to show a percentage for each each category, but i can only get the percentage of all transactions, and not the percentage of that month.
here is part of the code:
Code:
$result1 = mysql_query("SELECT date, category, type, amount, sum(amount)
FROM transactions
WHERE username = '$username' and category != 'transfer' and type != 'income'
GROUP by category, year(date), month(date)
ORDER by date desc");
echo "<h3>Transactions</h3>";
echo "<table border='1'>
<tr>
<td align='center'><b>Date</b></td>
<td align='center'><b>Category</b></td>
<td align='center'><b>Amount</b></td>
<td align='center'><b>Percent</b></td>
</tr>";
echo $sum;
while($row = mysql_fetch_array($result1))
{
echo "<tr>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['category'] . "</td>";
echo "<td>" . number_format($row['sum(amount)'], 2) . "</td>";
//$sum += $row['sum(amount)'];
$cat = ($row['sum(amount)']/$sum)*100;
echo "<td>" . number_format($cat, 2) . "</td>";
echo "</tr>";
}
echo "</table>";