I had to modify my the code of course for the new SELECT, and by tweaking the SQL statement further, I was able offload the sorting to the DB since I wanted the results displayed by the highest total to the lowest.
PHP Code:
$dbquery = $DB_site->query("SELECT field5, COUNT(field5) AS total FROM " . TABLE_PREFIX . "userfield GROUP BY field5 ORDER BY total DESC");
while ($queryrow = $DB_site->fetch_array($dbquery))
{
$f5stat .= $queryrow['total'] . " " . $queryrow['field5'];
}
There was a bit of extra html layout code in there as well, but for easier readability I left it out.
Much simpler execution to the problem. Again, many thanks! :up: