Jump to content

Add up int values in records


mrt003003

Recommended Posts

Hi there im trying to add up the number of different values i have in a table and echo the results:

 

Ships

------

ShipID INT: auto count

ShipName VARCHAR: Something

Class INT: (either 1 to 4)

 

The class row is the one i want to count, so if i have say 5 ships; first class 1, second class 2, third class 3, fourth class 4 and fith another class 1. It would total how many of each classes i have: two class 1, one class 2, one class 3 and one class 4.

 

Ultimately i am going to do a similar count on another table and compare the results, but thats for later as im really not sure where to start. Ive created a query selecting all the appropriate ships to be tallied up:

 

}
mysql_select_db($database_swb, $swb);
$query_Ships = sprintf("SELECT * FROM ships WHERE PlayerName = %s", GetSQLValueString($colname_Ships, "text"));
$Ships = mysql_query($query_Ships, $swb) or die(mysql_error());
$row_Ships = mysql_fetch_assoc($Ships);
$totalRows_Ships = mysql_num_rows($Ships);

 

If you could please help me that would be ace!

 

Thank You :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/235118-add-up-int-values-in-records/
Share on other sites

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.