I need help to make a forward button and return the month from a list of birthdays. The data will be sent via POST to a class that does the query. The PHP
part is ok. I need to adapt JavaScript
.
PHP
$data = date('Y-m-d');
$data_explode = explode("-", $data);
$dia = $data_explode[2];
$mes = $data_explode[1];
$ano = $data_explode[0];
$v_mes = substr($mes, 0, 2); //voltar mes
$novo_mes = (int) $mes - 1; //avancar mes
$botoes_mes = '<div class="medium-2 columns float-left">
<a id="#action-aniver" rel="' . $v_mes . '"><i class="fi-arrow-left"></i></a></div>
<div class="medium-8 columns float-center">
<h4 class="text-center">' . $mes . '</h4>
</div>
<div class="medium-2 columns">
<a id="#action-aniver" rel="' . $novo_mes . '"><i class="fi-arrow-right float-right"></i></a>
</div>';
Ajax Class:
case 'aniversario':
$char = $_POST['val'];
$body = '';
$dados = connection::select("SELECT * from aniversarios where MONTH(data_usuario) = '" . $char . "'");
foreach ($dados as $reg) {
$body .= '<p>' . $reg['nome'] . '</p>';
}
retorno = $body;
break;
JavaScript
$('#action-aniver').click(function () {
var chars = (this.value);
$.post(URL + 'Ajax/aniversario', {val: chars}, function (busca) {
$('#aniver-ajax').html(busca);
});
});