Jump to content

How To Sum The Amount From Table Field?


adilamarwat
 Share

Recommended Posts

You can probably do it like this:

// <-- Connect to database// Get rows$result = mysql_query ("SELECT id, item, price FROM inf") or die(mysql_error());// <-- Close Database$rownum = mysql_num_rows ($result);$i = 0;while ($i < $rownum) {   $price += mysql_result($result,$i,'price');   $i++;}echo "Total price is $price";

Hope it helps!

Edited by Kameloh
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...