Hello, I have a mysql table with one column (pieces). In the column pieces are many values e.g.(10 15 2). How to select from table and add all the values $query = "SELECT * FROM stats"; $result = mysql_query($query); $row = mysql_fetch_array($result); PHP: and now I want something like $total = $row['pieces']+$row['pieces']+...etc to be 27 in my e.g.; to add all pieces and put the value in a variable thank you
Run a quick query like this: $query = "SELECT SUM(pieces) as total FROM stats"; $result = mysql_query($query); $total = mysql_fetch_array($result); echo $total['total'];