How can I write a value into correct month which is located in an html table? Sorry for my bad English.
$mesi = array("January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December");
$array = $class->startEndDate('12'); // chiave arrays
echo '<table class="table table-bordered">';
echo '<thead>';
echo '<th class="text-center">Country</th>';
foreach ($mesi as $mese) {
echo '<th class="text-center">' . $mese . '</th>';
}
echo '</thead>';
echo '<tbody>';
echo '<tr>';
$query = "SELECT * FROM countries";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
echo '<td class = "text-center">' . $row['country_name'] . '</td>';
$sql = "select sum(quantity), country_id,
concat(year(date), '_', month(date)) as meseAnno
from subscription
where country_id = " . $row['country_id'] .
" group by meseAnno";
$res = mysql_query($sql);
while ($rows = mysql_fetch_assoc($res)) {
//the code here!
}
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
?>
With the second query I retrieve the subscription for country with id country_id.
Result of second query:
The column meseAnno of the first row says 2015_4, so April, but the value 7 is inserted in January. Why?
Thanks in advanced.