Re: Incrementing variables based on database data

From: Date: Wed, 13 Aug 2008 00:37:06 +0000
Subject: Re: Incrementing variables based on database data
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-278013@lists.php.net to get a copy of this message
Vinny Gullotta wrote:
Well, what I need to be able to do is then take the numbers of each count and figure out which is used the most. We use this database to log actions taken on servers in our network. What my boss wants me to come up with is a list of which commands are issued the most, which servers get the most attention, and for each server, which command is issued the most, and so I was going to kind of do it messy-like as I'm not really 100% sure of the best way to do it, but my goal was to create the count variables and then compare them using if statements to see which one is used the most. If you have a way of doing this more efficiently, I'd love to hear it. I'm not the best programmer in the world and I'm kind of just getting back into this stuff, so I'm all ears for any suggestions you may have =)
you can do it with one sql query. i don't know the real names of your columns so i'm just going to make some up. select message_type, count(1) x from table group by message_type order by x desc you can do the same thing for machines - just change message_type to machine_name. -jsd-

« previous php.general (#278013) next »