My code is as follows:
//Receber o número da página
$pagina_atual = filter_input(INPUT_GET,'pagina', FILTER_SANITIZE_NUMBER_INT);
$pagina = (!empty($pagina_atual)) ? $pagina_atual : 1;
//Setar a quantidade de itens por pagina
$qnt_result_pg = 8;
//calcular o inicio visualização
$inicio = ($qnt_result_pg * $pagina) - $qnt_result_pg;
$result_usuarios = "SELECT * FROM posts LIMIT $inicio, $qnt_result_pg";
$resultado_usuarios = mysqli_query($conn, $result_usuarios);
while($row_usuario = mysqli_fetch_assoc($resultado_usuarios)){
echo "<div class='post'>";
echo "<div class='wrap-ut pull-left'>";
echo "<div class='userinfo pull-left'>";
echo "<div class='avatar'>";
echo "<img src='styles/avatare.jpg' alt=''>";
echo "<div class='status yellow'> </div>";
echo "</div>";
echo "<div class='icons'>";
echo "<a href='" . utf8_encode($row_usuario['downurl']) . "'><img title='Clique para baixar!' src='styles/icon2.png' alt=''></a><img height='22' title='Verificado!' src='styles/icon1.png' alt=''>";
echo "</div>";
echo "</div>";
echo "<div class='posttext pull-left'>";
echo "<h2><strong>" . utf8_encode($row_usuario['title']) . "</strong></h2>";
echo "<hr>";
echo "<iframe width='500' height='250' src='https://youtube.com/embed/" . utf8_encode($row_usuario['yturl']) . "' frameborder='0' allowfullscreen></iframe>";
echo "<br /> <br />";
echo "<strong>➜ Descrição:</strong> <font color='black'>" . utf8_encode($row_usuario['description']) . "</font>";
echo "<hr>";
echo "Data: " . utf8_encode($row_usuario['date']);
echo "</div>";
echo "<div class='clearfix'></div>";
echo "</div>";
echo "<div class='clearfix'></div>";
echo "</div>";
}
//Paginção - Somar a quantidade de usuários
$result_pg = "SELECT COUNT(id) AS num_result FROM posts";
$resultado_pg = mysqli_query($conn, $result_pg);
$row_pg = mysqli_fetch_assoc($resultado_pg);
//echo $row_pg['num_result'];
//Quantidade de pagina
$quantidade_pg = ceil($row_pg['num_result'] / $qnt_result_pg);
//Limitar os link antes depois
$max_links = 2;
echo "<a href='index.php?pagina=1'>Início</a> ";
for($pag_ant = $pagina - $max_links; $pag_ant <= $pagina - 1; $pag_ant++){
if($pag_ant >= 1){
echo "<a href='index.php?pagina=$pag_ant'>$pag_ant</a> ";
}
}
echo "$pagina ";
for($pag_dep = $pagina + 1; $pag_dep <= $pagina + $max_links; $pag_dep++){
if($pag_dep <= $quantidade_pg){
echo "<a href='index.php?pagina=$pag_dep'>$pag_dep</a> ";
}
}
echo "<a href='index.php?pagina=$quantidade_pg'>Fim</a>";
?>
This code is reading what you have in the database and playing to the Php page, but it reads the first post for the last one, needs to read from the last post to the first
In case when I publish something in MySQL it will appear on my Site, however it appears the oldest post, and the new one it plays down.
I need the new ones to appear up, and the old ones down.
Can you help? Thanks!