I am having trouble with return sum data in MYSQLI and PHP. Here is my database.
For example,i choose user_id = '0', and i need to sum the number in m_debit and deduct m_credit for user_id = '0' to get the final total. The result should be like this:
The total should be appear in Metallic Point column
here is my current coding:
$get_member = "select sum (m_debit) from transaction_record_tpg where user_id = 0 ";
$run_customer = mysqli_query($conn,$get_member);
$a = mysqli_num_rows($run_customer);
can you guys help me to get the result?
[Updated] Below is my new coding but it doesnt work
<?php
$get_member = "SELECT SUM(m_debit) - SUM(m_credit) AS metallic_point FROM transaction_record_tpg WHERE user_id = 0";
$run_customer = mysqli_query($conn,$get_member);
$row = mysqli_fetch_row($run_customer);
?>
<tr>
<td><?php echo $row; ?></td>
<td>2018-10-15 11:03:13</td>
<td>TMA</td>
<td>2018-12-15</td>
</tr><!-- tr Ends -->