there is a table of files in the database Mysql field - id field - section
There are 5 files id = 1 section = maps id = 2 section = maps id = 3 section = weapons id = 4 section = weapons id = 5 section = weapons
on exit should get maps-2 weapons-3
My code for some reason does not work, gives an error, help me fix it, where did I make it ???
<?php require_once ($_SERVER["DOCUMENT_ROOT"]."/database.php"); $count = 0; $array = array(); $result = mysql_query("SELECT section FROM files WHERE game='1' GROUP BY section"); if(mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { $array[$count] = $row; $count++; } $new_Array = array_count_values($array); foreach ($new_Array as $section=> $sum) { echo "$section ($sum)<br/>"; } } else { echo 'Файлов нет!'; } ?>
array_count_values
Generates an E_WARNING level error for each element that is not a string or an integer. And then no problems:$new_Array
is an empty array. - Indifferent