Incrementing variables based on database data

From: Date: Tue, 12 Aug 2008 20:40:39 +0000
Subject: Incrementing variables based on database data
Groups: php.general 
Request: Send a blank email to php-general+get-278002@lists.php.net to get a copy of this message
below is the output I'm seeing along with my code. There are 11425 items in the database, many of each of these possible values for $i[4], however you'll see from my Output that the $iiscount variable is the only one being incremented and it is getting incremented for every row in the table. Can anyone see anything I'm doing incorrectly? The data in this column in the table is formatted as TEXT. Thanks in advance for any help you can provide. =) 11425 0 0 0 0 0 0 0 ____________________________________________ $query = "SELECT * FROM table"; $result = mysql_query($query) or die(mysql_error()); $iiscount = 0; $cfcount = 0; $nlbcount = 0; $srcount = 0; $sacount = 0; $rebootcount = 0; $apccount = 0; $othercount = 0; while($i = mysql_fetch_row($result)) { if ($i[4] = "IISRESET") { $iiscount = $iiscount + 1; } elseif ($i[4] = "CF Restart") { $cfcount = $cfcount + 1; } elseif ($i[4] = "NLB STOP IISRESET") { $nlbcount = $nlbcount +1; } elseif ($i[4] = "Service Restart") { $srcount = $srcount + 1; } elseif ($i[4] = "Restart System Attendant") { $sacount = $sacount + 1; } elseif ($i[4] = "Reboot") { $rebootcount = $rebootcount + 1; } elseif ($i[4] = "APC Reboot") { $apccount = $apccount + 1; } elseif ($i[4] = "Other") { $othercount = $othercount + 1; } } echo $iiscount, "<br>"; echo $cfcount, "<br>"; echo $nlbcount, "<br>"; echo $srcount, "<br>"; echo $sacount, "<br>"; echo $rebootcount, "<br>"; echo $apccount, "<br>"; echo $othercount, "<br>"; ?>

« previous php.general (#278002) next »