I've got this code:
for ($d=1;$d<=$diesmes;$d++){$dia[$d]=0;} // This creates an array of days_of_month items with value 0
$q_lectures = mysql_query ("SELECT DAYOFMONTH(data_llegit) AS dia,COUNT(DAYOFMONTH(data_llegit)) AS penya FROM proj".$id_projecte."_emails_llegits WHERE MONTH(data_llegit) = MONTH(NOW()) AND YEAR(data_llegit) = YEAR(NOW()) GROUP BY DAYOFMONTH(data_llegit)") or die("2".mysql_error());
while ($myrow = mysql_fetch_array($q_lectures) ){$dia[$myrow[dia]]=$myrow[penya];} // This replaces the 0 values with values out of database (where available)
$lectures = mysql_num_rows($q_lectures);
# Everything ok just until here. Now here the troubling code comes:
$maxim = max($dia) + 10 - (max($dia) % 10); // Although $dia[17] is 11 and $dia[18] is 14 (as I may see printing all the array using for), max($day) always returns 0
What am I doing wrong? Shouldn't max($dia) return 14 (which is the highest value)?