Jump to content

[SOLVED] Adding items in same field


timmah1

Recommended Posts

I have a database that has three fields (id, user, amount)

 

I want to add all of the data in the amount field by user.

 

I know how to add items and so forth, but I'm not sure how to do it this way.

 

If there are four entries in the database

id user amount

1  test  4

6  test1  8

2  test  9

3  test  8

 

How would I add all the amount fields for user test?

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/111762-solved-adding-items-in-same-field/
Share on other sites

ok, obviously, I'm not doing this right

 

$deposit_sql="SELECT SUM(amount), username, deposited, type FROM bank WHERE username = '$username' GROUP BY username";
$result = mysql_query($deposit_sql);
$numrows = mysql_num_rows($result)
or die("Sorry, there was a problem selecting your account ".mysql_error());
while($row = mysql_fetch_array($result)) { 
echo $row['amount'];
}

 

Nothing shows up

 

Any insight?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.