I need to find the most common value (not 0) from arrays. My code:
include ("db.php");
$query = "SELECT poll1 FROM names";
$res = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($res)) {
echo $row['poll1'];
}
And echo results (minimum value 0 (default) and maximum 3):
1
1
0
0
0
2
3
The most common value is "1". I cant use array_count_values, because there are 7 arrays of numbers.
mysql_**
functions are deprecated? You'd better usePDO
instead.COUNT()
aggregate:SELECT poll1, COUNT(*) AS count FROM names GROUP BY poll1