Shawn Posted March 11, 2006 Share Posted March 11, 2006 I use...$query=mysql_query("select * from record where id='$id');It choose line 1,5,8 in record.And I want to sum object 'print' in this 3 line.How to write the script?? Thanks a lot, a lot. Link to comment Share on other sites More sharing options...
hacknsack Posted March 12, 2006 Share Posted March 12, 2006 I think you mean you have a table named record that has a field named print and you want to total that field using the data from each row returned. $query = mysql_query("select * from record where id='$id'");$objSum = 0;while ($row = mysql_fetch_array($query)) { $objSum += $row['print']; }echo $objSum; Let us know if that is not what you meant.-hs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now