0
On this page I’m making birthday of the month, and I was able to display all the birthdays that have in the current month, but I’m not able to display the day and I also selected in the database...
<?php
require 'cfg/db.php';
$conexao = conexao::getInstance();
$sql = 'SELECT id, nome, membro, foto, data_nascimento, DAY(data_nascimento) FROM membros WHERE DAY(data_nascimento) AND MONTH(data_nascimento)';
$stm = $conexao->prepare($sql);
$stm->execute();
$aniversariantes = $stm->fetchAll(PDO::FETCH_OBJ);
print_r($aniversariantes);
?>
<?php
foreach($aniversariantes as $aniversariante):
?>
<tr class="table-row">
<td class="table-img">
<img src='fotos/<?=$aniversariante->foto?>' height='40' width='40'>
</td>
<td class="table-text">
<h6><?=$aniversariante->nome?></h6>
<p><?=$aniversariante->membro?></p>
</td>
<td class="march">
Dia:
</td>
</tr>
<?php
endforeach;
?>
worked out, thanks a lot ! you could help me in one more thing?
– Leonardo Ribeiro
what the doubt? If it is too extensive the ideal is to create a new question.
– Roberto de Campos
is that she is in yyyyyy/mm/dd wanted to put her in the format of Brazil
– Leonardo Ribeiro
To format the date you use the function
DATE_FORMAT
, then it would look like thisDATE_FORMAT(DATE(data_nascimento), "%d/%m/%Y") AS dia_nascimento
in place ofDAY(data_nascimento) AS dia_nascimento
.– Roberto de Campos
I did, thank you very much !
– Leonardo Ribeiro