Afisare rezultate paginate la scroll page
Scris: Vin Dec 11, 2020
Salut,
In baza de date am 23 de rezultate din care initial afisez doar 10 si as vrea ca atunci cand ajung cu scroll la finalul paginii sa imi afiseze inca 10 pana le afiseaza pe toate.Am facut scriptul asta doar ca afiseaza doar primele 10 si atat...unde gresesc?Multumesc!
afisare.php
script_afisare.php
In baza de date am 23 de rezultate din care initial afisez doar 10 si as vrea ca atunci cand ajung cu scroll la finalul paginii sa imi afiseze inca 10 pana le afiseaza pe toate.Am facut scriptul asta doar ca afiseaza doar primele 10 si atat...unde gresesc?Multumesc!
afisare.php
Cod: Selectaţi tot
<style>
.question {font-weight:bold;background-color:#FFF;padding:7px 0px 0px 15px;}
.answer{font-style:italic;background-color:#FFF;padding:0px 0px 7px 15px;}
#faq-result{margin: -10px auto 0px;width:50%;line-height:30px;border-radius:5px;min-height:300px;}
#loader-icon {position: fixed;top: 50%;width:100%;height:100%;text-align:center;display:none;}
</style>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.2.6.pack.js"></script>
<script>
$(document).ready(function(){
function getresult(url) {
$.ajax({
url: url,
type: "GET",
data: {rowcount:$("#rowcount").val()},
beforeSend: function(){
$('#loader-icon').show();
},
complete: function(){
$('#loader-icon').hide();
},
success: function(data){
$("#faq-result").append(data);
},
error: function(){}
});
}
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
if($(".pagenum:last").val() <= $(".total-page").val()) {
var pagenum = parseInt($(".pagenum:last").val()) + 1;
getresult('script_afisare.php?page='+pagenum);
}
}
});
});
</script>
</HEAD>
<BODY>
<div id="faq-result">
<?php include('script_afisare.php'); ?>
</div>
<div id="loader-icon"><img src="LoaderIcon.gif" /><div>
</BODY>
</HTML>
Cod: Selectaţi tot
<?php
include"header.php";
require_once("include/functii.php");
$perPage = 10;
$page = 1;
if(!empty($_GET["page"])) {
$page = $_GET["page"];
}
$start = ($page-1)*$perPage;
if($start < 0) $start = 0;
$mydb->setQuery("SELECT * from php_interview_questions limit $start,$perPage");
$faq = $mydb->executeQuery();
$nr = $mydb->num_rows($faq);
if(empty($_GET["rowcount"])) {
$_GET["rowcount"] = $nr;
}
$pages = ceil($_GET["rowcount"]/$perPage);
$output = '';
if(!empty($faq)) {
$output .= '<input type="hidden" class="pagenum" value="' . $page . '" /><input type="hidden" class="total-page" value="' . $pages . '" />';
while($row = $faq->fetch_assoc()){
$output .= '<div class="question">' . $row["question"] . '</div>';
$output .= '<div class="answer">' . $row["answer"] . '</div>';
}
print $output;
}
?>