How can I count total value of a certain row in a field?
Table: Test
Field: access attempts
where row for access attempts would be any number from 0 - 1000
and I need to count total value of all rows with a value in access attempts
count total of ....
Moderator: General Moderators
- blacksnday
- Forum Contributor
- Posts: 252
- Joined: Sat Jul 30, 2005 6:11 am
- Location: bfe Ohio :(
-
RobertPaul
- Forum Contributor
- Posts: 122
- Joined: Sun Sep 18, 2005 8:54 pm
- Location: OCNY
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
You can use either array_sum() or you can loop through the result set and add each value by concatenating.
Code: Select all
<?php
while ( $row = mysql_fetch_array($result) )
{
$row_total += $row['access_attempts'];
}- blacksnday
- Forum Contributor
- Posts: 252
- Joined: Sat Jul 30, 2005 6:11 am
- Location: bfe Ohio :(