How to do this li list from the smallest date to the largest?
<div class="cal1"></div>
<?
$inicio = date('Y').'-01-01';
$fim = date('Y').'-12-31';
$iniciomes = date('Y-m').'-01';
$fimmes = date('Y-m').'-31';
//programacao letiva
$pdo = Database::conexao();
$cal = $pdo->prepare('SELECT * FROM olmp_calendario WHERE data BETWEEN ? AND ? AND turma = ? AND unidade = "go"');
$cal -> bindParam(1, $iniciomes, PDO::PARAM_STR);
$cal -> bindParam(2, $fimmes, PDO::PARAM_STR);
$cal -> bindParam(3, $_GET['turma'], PDO::PARAM_STR);
// todos os eventos do ano
$ev = $pdo->prepare('SELECT * FROM olmp_calendario WHERE data BETWEEN ? AND ? AND turma = ? AND unidade = "go"');
$ev -> bindParam(1, $inicio, PDO::PARAM_STR);
$ev -> bindParam(2, $fim, PDO::PARAM_STR);
$ev -> bindParam(3, $_GET['turma'], PDO::PARAM_STR);
$ev -> execute();
if($cal -> execute()){
echo "<ul class='listaEventos'>";
echo "<li class='titLista'>Programação letiva - ".$nTurma."</li>";
while($c = $cal->fetch(PDO::FETCH_ASSOC)){
echo "<li><strong>".formataData($c['data'],'php')."</strong> - ".$c['dadosevento']."</li>";
}
echo "</ul>";
}
?>
<div class="clear"></div>
<div class="legCal">
<div class="hj"></div><span>Hoje</span>
<div class="diaEv"></div><span>Evento</span>
</div>
<script src="<?=OLIMPO;?>js/jquery2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script><scriptsrc="<?=OLIMPO;?>js/moment2.js"></script>
<? echo '<script src="'.OLIMPO.'js/clndr.js?'.date("YmdHis", filemtime("js/clndr.js")).'"></script>';?>
<? echo '<script src="'.OLIMPO.'js/moment.locale.js?'.date("YmdHis", filemtime("js/moment.locale.js")).'"></script>';?>
<script src="<?=OLIMPO;?>js/moment-timezone-with-data.js"></script>
<? echo '<link rel="stylesheet" href="'.OLIMPO.'css/clndr.css?'.date("YmdHis", filemtime("css/clndr.css")).'"/>';?>
<script type="application/javascript">
// Call this from the developer console and you can control both instances
var calendars = {};
$(document).ready( function() {
//define o idioma: pt-BR
moment.locale('pt-BR');
moment.tz.setDefault("America/New_York");
// Here's some magic to make sure the dates are happening this month.
var thisMonth = moment().format('YYYY-MM');
// Events to load into calendar
var eventArray = [
<?
while($ca = $ev->fetch(PDO::FETCH_ASSOC)){?>
{
date: '<?=$ca['data'];?>',
title: '<?=$ca['dadosevento'];?>'
},
<? } ?>
];
// The order of the click handlers is predictable. Direct click action
// callbacks come first: click, nextMonth, previousMonth, nextYear,
// previousYear, nextInterval, previousInterval, or today. Then
// onMonthChange (if the month changed), inIntervalChange if the interval
// has changed, and finally onYearChange (if the year changed).
calendars.clndr1 = $('.cal1').clndr({
constraints: {
endDate: '<?=$fim;?>',
startDate: '<?=$inicio;?>'
},
events: eventArray,
clickEvents: {
onMonthChange: function (month) {
var curMes = month.format('MM');
carregaEventos(curMes);
}
},
multiDayEvents: {
singleDay: 'date',
},
showAdjacentMonths: false,
adjacentDaysChangeMonth: false,
});
function carregaEventos(mes){
var turma = '<?=$_GET['turma']?>';
$.ajax({
type: 'POST',
url:"<?=OLIMPO;?>ctrlSite.php",
data:'acao=buscaEventos&mes='+mes+'&turma='+turma,
dataType:"json",
success: function(data){
$('.listaEventos').empty();
$('.listaEventos').append('<li class="titLista">Programação letiva - <?=$nTurma;?></li>');
for(var i=0; i<data.length;i++){
$('.listaEventos').append('<li><strong>'+data[i]['data']+'</strong> - '+data[i]['dados']+'</li>');
}
}
});
}
// Bind all clndrs to the left and right arrow keys
$(document).keydown( function(e) {
// Left arrow
if (e.keyCode == 37) {
calendars.clndr1.back();
}
// Right arrow
if (e.keyCode == 39) {
calendars.clndr1.forward();
}
});
});
</script>