Ok I have a column called earn in my users table. How can I get the sum of all the earn totals from the whole table?
Do you mean SQL to get the total? If so here it is select sum(earn) from users. if not disgrard or tell in more
kashem is right. MakeThatDollar, you can also write in this way: "select sum(earn) as total from users"; then print the total through a variable.
Here's what I have so far: Query to get the total: $sumquery = "SELECT sum(earn) FROM users"; $sumearn = mysql_query($sumquery); Code to display the total: <td align="center"><b><? echo $sumearn; ?></b></td> What is actually displayed: Resource id #48 I'm not sure why it's display "Resource id #48" when it should be display a total like $x.xx or something.
Write like this: $sumquery = "SELECT sum(earn) as total FROM users"; $sumearn = mysql_query($sumquery); $rwSum = mysql_fetch_array($sumearn); $totalEarn = $rwSum['total']; Code to display the total: <td align="center"><b><? echo $totalEarn; ?></b></td>