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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.