Sorry, I seem to have left my PHP books at the office, but I had a quick question that someone should hopefully be able to answer.
I'm writing a little stat hack for my members that will count the number of users of various interests that I'll display in my Site Stats row of the main forum page.
My stats will be generated off the custom "field5" (listed in the DB as "field5"), which is a pulldown that lists 5 or 6 options, and the member can pick one. I don't care about usernames, etc. I just want raw stats. This is example code of what I wanted to use, but I'm not sure about the array stuff. I want the text key for the array to match the text of the option in the pulldown, and increment it if there's a match from the database row from my select statement.
Code:
$field5stat = array();
$dbquery = $DB_site->query("SELECT field5 FROM " . TABLE_PREFIX . "userfield ASC");
while ($queryrow = $DB_site->fetch_array($dbquery))
{
$field5stat[$queryrow['field5']]++
}
What I'm hoping that last line does is say, if field5 is 'blue', then $field5stat['blue'] should be incremented.
Will that work, or is my syntax of either the array or incrementing wrong?
Thanks for any assistant, my PHP coding skills are rather rusty as I haven't programmed in it for about 4 years *laughs*