Below I am adding all dollar amounts from a column in a table called transactions.
It works just fine.
$result = mysql_query("SELECT SUM(amount) AS lump FROM transactions");
$row = mysql_fetch_array( $result );
echo "amount: ".$row['lump'];
This gets me what I wanted, all amounts added together.
BUT!
When I try to add another table to the query, like the customers table I get errors.
$result = mysql_query("SELECT SUM(t.amount) AS lump, c.status FROM transactions t, customer c WHERE t.customer_id = c.customer_id AND c.status = 'Active' ");
$row = mysql_fetch_array( $result );
echo "amount: ".$row['lump'];
the $row['lump'] stops working completely.
Any ideas why adding multiple tables to the query cause it to halt?