I trying to create Show Month in ajax, but the output is a number of month like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. I want month be January, February, March .. December
Here's my code:
function list_bulan($id_tahun){
$sql ="SELECT DISTINCT(MONTH(waktu)) AS bulan FROM aktiv WHERE YEAR(waktu) = $id_tahun ORDER BY MONTH(waktu) ASC";
$query = $this->db->query($sql);
$html = "<option value=''>-- Pilih bulan --</option>";
foreach ($query->result_array() as $value) {
if ($value['bulan'] == 1) {
// january
echo january;
}
$html .=
"<option value='".$value['bulan']."'>"
.$value['bulan']. // how to create if in this line? i'm try but with no success
"</option>";
}
echo $html;
}
How create a name of month inside foreach? Any answer?