0
I looked at some sites and saw some things about it, but I’m not getting the logic behind the page on demand.
jQuery(document).ready(function(){
jQuery('#btnpaginas').click(function(){
var dados = jQuery( this ).serialize();
jQuery.ajax({
type: "POST",
url: "paginacao.php",
data: dados,
success: function(data)
{
$(".paginacao").html(data);
}
});
return false;
});
});
<button id="btnpaginas">Carregar mais</button>
PHP
$inicio = 5;
$stmt = $conecta->prepare("select * from postagem order by idpost desc limit $inicio " );
$stmt->execute();
I know I’m doing it wrong. It already starts with 1 record and when I press the "press more" button it shows the first record, which already had, and four more. Only with this code that I made, it will not load 5 more if I click again, I want to know how to do for whenever I click the button, it show 5 more records to my posting system.
Lendro, the idea is that when you click on the "press more" button automatically appear 5 more posts below the existing ones. It’s a site where there will be a lot of people doing a lot of posts, like facebook, but without automatic scrolling. From what I saw this code that you put will only show up to 5 posts at most. The idea is not to use select in this case. Have some other idea?
– Luizinho
Sorry, after your comment I realized that I misunderstood your question. I edited the answer, but it won’t do much good. When the person clicks on the button, a request will be made for your file. php, in the file will be made a query and you will return the result of this query pro your html file, and you have to handle the result of the query within the function
success()
, very likely to be received aarray
and the ideal is to treat it with aforeach
.– Leandro Lima