Pagination Selected Limits gets reset when clicks next / previous button - javascript

The table result filter by limit gets reset when the pagination action done. If I select limit 10 from the dropdown and click next, the limit automatically reset to 5 which is the default
<?php
$limit = isset($_POST['limit-records']) ? $_POST['limit-records'] : 5;
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$start = ($page - 1) * $limit;
if($_SESSION['access'] == "user"){
$sql = "SELECT * FROM `enquiry list` WHERE `designated_staff` = ? ORDER BY `enquiry list`.`ID` DESC LIMIT $start, $limit";
$result = $conn->prepare($sql);
$result->execute([$_SESSION['user']]);
}else{
$sql = "SELECT * FROM `enquiry list` ORDER BY `enquiry list`.`ID` DESC LIMIT $start, $limit";
$result = $conn->prepare($sql);
$result->execute();
}
$total = $conn->prepare("SELECT * FROM `enquiry list`");
$total->execute();
$count = $total->rowCount();
$pages = ceil($count / $limit);
$prev = $page - 1;
$next = $page + 1;
?>
Pagination Drop Down
<form method="post">
<select class="form-control" name="limit-records" id="limit-records">
<option disabled = "disabled" selected = "selected">Result Views</option>
<?php foreach([5,10,15,20,25] as $limit):?>
<option <?php if(isset($_POST['limit-records']) && $_POST['limit-records']==$limit) echo "selected" ?> value="<?php echo $limit; ?>"><?php echo $limit; ?></option>
<?php endforeach;?>
</select>
</form>
JQuery Submit
<script type="text/javascript">
$(document).ready(function(){
$("#limit-records").change(function(){
$("form").submit();
});
});
</script>

limits variable should be GET not POST like that
$limit = isset($_GET['limit-records']) ? $_GET['limit-records'] : 5;
change your page logic

Assuming that you got this pagination logic from here
Every time you access the pagination links, the posted limit variable is lost and therefore resets to the default value. The way I solved this is by converting the pagination links to html forms. That way, you can redirect with the pages intact and still pass on the current limit value using a hidden input.
<div class="col-md-10">
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item <?php echo $page == 1 ? 'disabled' : ''; ?>">
<form id="pagination-button"action="viewRecords.php?page=<?= $Previous;?>" method="POST">
<input type="hidden" id="page-itemlink" name = limit-records value = "<?php echo $limit; ?>">
<button type ="submit"class="page-link" aria-label="Previous">
<span aria-hidden="true">« Previous</span>
</button>
</form>
</li>
<?php for($i = 1; $i<= $pages; $i++) : ?>
<li class="page-item ">
<form id="pagination-button" action="viewRecords.php?page=<?= $i;?>" method="POST">
<input type="hidden" id="page-itemlink" name = limit-records value = "<?php echo $limit; ?>">
<button type="submit" class="page-link" ><?= $i; ?></button>
</form>
</li>
<?php endfor; ?>
<li class="page-item <?php echo $page == $pages ? 'disabled' : ''; ?>">
<form id="pagination-button" action="viewRecords.php?page=<?= $Next;?>" method="POST">
<input type="hidden" id="page-itemlink" name = limit-records value = "<?php echo $limit; ?>">
<button type="submit" class="page-link" aria-label="Next">
<span aria-hidden="true">Next »</span>
</button>
</form>
</li>
</ul>
</nav>
</div>

Related

Option buttons don't reload page automatically in PHP, I cannot find the error in my code

I am working on my PHP assignment and I want to use option buttons, which reload the page automatically when I choose between them. I tried to figure out what the problem might be, but I can't find the error in the code. Below is what I've done so far, but it doesn't work for some reason.
This is my javascript code(album-list.js):
document.getElementById("album-sort").addEventListener("change", function (e) {
let current_url = window.location.href
window.location = updateQueryStringParameter(current_url, "sort", e.value)
})
This is my own function:
function get_album_list($offset = 0, $limit = PAGE_LIMIT, $artist = null, $sorting = "title_asc")
{
global $db;
$sql = "SELECT * FROM albums";
if ($artist) {
$artist = $db->real_escape_string($artist);
$sql .= " WHERE artist = '$artist'";
}
$order = "";
switch ($sorting) {
case "title_desc":
$order = " ORDER BY title DESC";
break;
case "year_asc":
$order = " ORDER BY year ASC";
break;
case "year_desc":
$order = " ORDER BY year DESC";
break;
default:
$order = " ORDER BY title ASC";
break;
}
$sql .= $order;
$sql .= " LIMIT $limit OFFSET $offset";
$result = $db->query($sql);
return $result;
}
This is where I want to use:
<?php
$artist = isset($_GET["artist"]) ? $_GET["artist"] : null;
$sort = isset($GET["sort"]) ? $_GET["sort"] : "title_asc"; // Here is the mistake. $GET--> $_GET
$current_page = isset($_GET['page']) ? $_GET['page'] : 1;
$limit = ($current_page - 1) * PAGE_LIMIT;
$total_pages = get_album_count($artist) / PAGE_LIMIT;
$albums = get_album_list($limit, PAGE_LIMIT, $artist, $sort);
?>
<?php
<div class="page page-albums">
<h2>Just for you</h1>
<?php if ($albums->num_rows <= 0) : ?>
<div class="alert alert-warning">
There is no album
</div>
<?php else : ?>
<div class="album-list">
<select id="album-sort">
<option value="title_asc">Title asc</option>
<option value="title_desc">Title desc</option>
<option value="year_asc">Release date asc</option>
<option value="year_desc">Release date desc</option>
</select>
<?php while ($album = $albums->fetch_assoc()) : ?>
<?php include('_album_list_item.php'); ?>
<?php endwhile; ?>
</div>
<ul class="pagination">
<?php for ($i = 1; $i < $total_pages + 1; $i++) : ?>
<li>
<?php if ($i == $current_page) : ?>
<span><?php echo $i; ?></span>
<?php else : ?>
<?php echo $i; ?>
<?php endif; ?>
</li>
<?php endfor; ?>
</ul>
<?php endif; ?>
</div>
<script src="<?php echo asset('js/album-list.js'); ?>"></script>
<?php include "functions.php"; ?>
Try adding this to your album-list.js file.
function updateQueryStringParameter(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
}
}
In answer to your other question:
<?php
$artist = isset($_GET["artist"]) ? $_GET["artist"] : null;
$sort = isset($_GET["sort"]) ? $_GET["sort"] : "title_asc";
$current_page = isset($_GET['page']) ? $_GET['page'] : 1;
$limit = ($current_page - 1) * PAGE_LIMIT;
$total_pages = get_album_count($artist) / PAGE_LIMIT;
$albums = get_album_list($limit, PAGE_LIMIT, $artist, $sort);
$titleSelect1 = '';
$titleSelect2 = '';
$titleSelect3 = '';
$titleSelect4 = '';
if($sort == 'title_asc'){
$titleSelect1 = 'selected';
}
if($sort == 'title_desc'){
$titleSelect2 = 'selected';
}
if($sort == 'year_asc'){
$titleSelect3 = 'selected';
}
if($sort == 'year_desc'){
$titleSelect4 = 'selected';
}
?>
<?php
<div class="page page-albums">
<h2>Just for you</h1>
<?php if ($albums->num_rows <= 0) : ?>
<div class="alert alert-warning">
There is no album
</div>
<?php else : ?>
<div class="album-list">
<select id="album-sort">
<option value="title_asc" <?php echo $titleSelect1;?>>Title asc</option>
<option value="title_desc" <?php echo $titleSelect2;?>>Title desc</option>
<option value="year_asc" <?php echo $titleSelect3;?>>Release date asc</option>
<option value="year_desc" <?php echo $titleSelect4;?>>Release date desc</option>
</select>
<?php while ($album = $albums->fetch_assoc()) : ?>
<?php include('_album_list_item.php'); ?>
<?php endwhile; ?>
</div>
<ul class="pagination">
<?php for ($i = 1; $i < $total_pages + 1; $i++) : ?>
<li>
<?php if ($i == $current_page) : ?>
<span><?php echo $i; ?></span>
<?php else : ?>
<?php echo $i; ?>
<?php endif; ?>
</li>
<?php endfor; ?>
</ul>
<?php endif; ?>
</div>
<script src="<?php echo asset('js/album-list.js'); ?>"></script>
<?php include "functions.php"; ?>
After I reviewed your answer again and thinking for a while, I came to the conclusion that it might be possible to solve this in a shorter way. Since it still works, I think the code is right, but correct me if I'm wrong.
<?php
$artist = isset($_GET["artist"]) ? $_GET["artist"] : null;
$sort = isset($_GET["sort"]) ? $_GET["sort"] : "title_asc";
$current_page = isset($_GET['page']) ? $_GET['page'] : 1;
$limit = ($current_page - 1) * PAGE_LIMIT;
$total_pages = get_album_count($artist) / PAGE_LIMIT;
$albums = get_album_list($limit, PAGE_LIMIT, $artist, $sort);
?>
<?php include "_header.php"; ?>
<div class="page page-albums">
<h2>Just for you</h1>
<?php if ($albums->num_rows <= 0) : ?>
<div class="alert alert-warning">
There is no album
</div>
<?php else : ?>
<div class="album-list">
<select id="album-sort">
<option value="title_asc" <?php echo isset($_GET["sort"]) ? $_GET["sort"] == "title_asc" ? "selected" : "" : ""?> >Title asc</option>
<option value="title_desc" <?php echo isset($_GET["sort"]) ? $_GET["sort"] == "title_desc" ? "selected" : "" : ""?> >Title desc</option>
<option value="year_asc" <?php echo isset($_GET["sort"]) ? $_GET["sort"] == "year_asc" ? "selected" : "" : ""?> >Release date asc</option>
<option value="year_desc" <?php echo isset($_GET["sort"]) ? $_GET["sort"] == "year_desc" ? "selected" : "" : ""?> >Release date desc</option>
</select>
<?php while ($album = $albums->fetch_assoc()) : ?>
<?php include('_album_list_item.php'); ?>
<?php endwhile; ?>
</div>
<ul class="pagination">
<?php for ($i = 1; $i < $total_pages + 1; $i++) : ?>
<li>
<?php if ($i == $current_page) : ?>
<span><?php echo $i; ?></span>
<?php else : ?>
<?php echo $i; ?>
<?php endif; ?>
</li>
<?php endfor; ?>
</ul>
<?php endif; ?>
</div>
<script src="<?php echo asset('js/album-list.js'); ?>"></script>
<?php include "_footer.php"; ?>

How to Create Load More With PHP and PDO

i want to create load more to my site, but when i try to click load more it just load 2 items.
my index.php
<div class="postList">
<?php
// Include the database configuration file
include 'koneksi.php';
// Get records from the database
$query = $db->prepare("SELECT * FROM master_post, posting WHERE master_post.master_post_name = posting.master_post_name AND posting.sticky = 'Normal' ORDER BY posting.idpost DESC LIMIT 2");
$query->execute();
if($query->rowCount() > 0){
while($row = $query->fetch()){
$postID = $row['idpost'];
?>
<div class="list_item"><?php echo $row['file_name']; ?></div>
<?php } ?>
<div class="show_more_main" id="show_more_main<?php echo $postID; ?>">
<span id="<?php echo $postID; ?>" class="show_more" title="Load more posts">Show more</span>
<span class="loding" style="display: none;"><span class="loding_txt">Loading...</span></span>
</div>
<?php } ?>
</div>
my javascript
<script type="text/javascript">
$(document).ready(function(){
$(document).on('click','.show_more',function(){
var ID = $(this).attr('id');
$('.show_more').hide();
$('.loding').show();
$.ajax({
type:'POST',
url:'ajax_more.php',
data:'id='+ID,
success:function(html){
$('#show_more_main'+ID).remove();
$('.postList').append(html);
}
});
});
});
</script>
my ajax_more.php
if(!empty($_POST["id"])){
// Include the database configuration file
include 'koneksi.php';
// Count all records except already displayed
$query = $db->prepare("SELECT COUNT(*) as num_rows FROM master_post, posting WHERE master_post.master_post_name = posting.master_post_name AND posting.sticky = 'Normal' AND posting.idpost < ".$_POST['id']." ORDER BY posting.idpost DESC");
$row = $query->fetch();
$totalRowCount = $row['num_rows'];
$showLimit = 2;
// Get records from the database
$query = $db->query("SELECT * FROM master_post, posting WHERE master_post.master_post_name = posting.master_post_name AND posting.sticky = 'Normal' AND posting.idpost < ".$_POST['id']." ORDER BY posting.idpost DESC LIMIT $showLimit");
if($query->rowCount() > 0){
while($row = $query->fetch()){
$postID = $row['idpost'];
?>
<div class="list_item"><?php echo $row['file_name']; ?></div>
<?php } ?>
<?php if($totalRowCount > $showLimit){ ?>
<div class="show_more_main" id="show_more_main<?php echo $postID; ?>">
<span id="<?php echo $postID; ?>" class="show_more" title="Load more posts">Show more</span>
<span class="loding" style="display: none;"><span class="loding_txt">Loading...</span></span>
</div>
<?php } ?>
<?php
}
}
I'm not sure where the mistake is. im using tutorial from this site https://www.codexworld.com/load-more-data-using-jquery-ajax-php-from-database/

form action add page search

I have a problem
I hope you understand I write English badly:
I created a search field that contains these two files
index.php
<?php
include('db.php');
$keySesso = $_GET['sesso'];
$keyEta = $_GET['eta'];
$keyRegione = $_GET['regione'];
$keyFoto = $_GET['foto'];
//sesso
if(isset($keySesso)){
if ($keySesso == 2) {
$FemminaE="selected";
}else if ($keySesso == 1){
$MaschioE="selected";
}else if ($keySesso == 26){
$Gay="selected";
}else if ($keySesso == 27){
$Lesbica="selected";
}else if ($keySesso == 29){
$FemminaB="selected";
}else if ($keySesso == 28){
$MaschioB="selected";
}else{
$sessoN="";
}
}
//for total count data
$countSql = "SELECT COUNT(last_activity) FROM _core_members INNER JOIN _core_pfields_content ON _core_members.member_id = _core_pfields_content.member_id $whereSQL $keyRegione $CondizioneEta $CondizioneFoto ";
$tot_result = mysqli_query($conn, $countSql);
$row = mysqli_fetch_row($tot_result);
$total_records = $row[0];
$total_pages = ceil($total_records / $limit);
//for first time load data
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $limit;
$sql = "SELECT * FROM _core_members INNER JOIN _core_pfields_content ON _core_members.member_id = _core_pfields_content.member_id $whereSQL $keyRegione $CondizioneEta $CondizioneFoto ORDER BY last_activity DESC LIMIT $start_from, $limit";
$rs_result = mysqli_query($conn, $sql);
?>
<!DOCTYPE html>
<head>
</head>
<body >
<div class="BloccoBaseBO">
<div class="container" id="BOcontent">
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tab1">
<form method='GET' id='FormChattaCon' class='FormBase' action=''>
<select id="SelectedSesso" name="sesso">
<option value="" <?php echo $sessoN; ?>>Tutti i generi</option>
<option value="2" <?php echo $FemminaE; ?>>femmine (Etero)</option>
<option value="1" <?php echo $MaschioE; ?>>maschi (Etero)</option>
<option value="26" <?php echo $Gay; ?>>Gay</option>
<option value="27" <?php echo $Lesbica; ?>>Lesbica</option>
<option value="29" <?php echo $FemminaB; ?>>Femmina (Bisex)</option>
<option value="28" <?php echo $MaschioB; ?>>Maschio (Bisex)</option>
</select>
<div class='ConFoto'>Con Foto: <input id="checkBox" name="foto" type="checkbox" onclick="javascript: submitform()" <?php echo $check;?>/> </div>
</form>
<table class="table table-bordered table-striped">
<tbody id="target-content">
<?php
while ($row = mysqli_fetch_assoc($rs_result)) {
echo "<div class='bloccoUserOnlineBO'></div><li class='NomeBloccoB'>$MemberName</li>";
};
?>
</tbody>
</table>
<nav><ul class="pagination">
<?php if(!empty($total_pages)):for($i=0; $i<=$total_pages; $i++):
if($i == 0):?>
<li class='active' id="<?php echo $i;?>"><a href='pagination.php?page=<?php echo $i;?>'><?php echo $i;?></a></li>
<?php else:?>
<li id="<?php echo $i;?>"><a href='pagination.php?page=<?php echo $i;?>'><?php echo $i;?></a></li>
<?php endif;?>
<?php endfor;endif;?>
</ul>
</nav>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('.pagination').pagination({
items: <?php echo $total_records;?>,
itemsOnPage: <?php echo $limit;?>,
cssStyle: 'light-theme',
currentPage : 0,
onPageClick : function(pageNumber) {
jQuery("#target-content").html('loading...');
jQuery("#target-content").load("pagination.php?page=" + pageNumber);
}
});
});
</script>
<!-- tab -->
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="js/jquery.scrolling-tabs.js"></script>
<script>
$('.nav-tabs').scrollingTabs();
</script>
<!-- FlexSlider -->
<script src="http://www..it/info-user-global/js/jquery.flexslider-min.js"></script>
<script src="http://www..it/info-user-global/js/main.js"></script>
the second where it is recalled from the pages
pagination.php
<?php
include('db.php');
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $limit;
$sql = "SELECT * FROM ILFREE_core_members INNER JOIN ILFREE_core_pfields_content ON ILFREE_core_members.member_id = ILFREE_core_pfields_content.member_id $whereSQL $keyRegione $CondizioneEta $CondizioneFoto ORDER BY last_activity DESC LIMIT $start_from, $limit";
$rs_result = mysqli_query($conn, $sql);
?>
<?php
while ($row = mysqli_fetch_assoc($rs_result)) {
echo "<div class='bloccoUserOnlineBO'></div><li class='NomeBloccoB'>$MemberName</li>";
};
?>
The problem is this
When I compile the form, the result appears only on the index.php page
When I push the buttons on the bottom pages linked to the pagination.php page, I reset the form
enter image description here
I can not fix it because the form data will stop at the index page but when I call the pagination.php file through this:
<script type="text/javascript">
$(document).ready(function(){
$('.pagination').pagination({
items: <?php echo $total_records;?>,
itemsOnPage: <?php echo $limit;?>,
cssStyle: 'light-theme',
currentPage : 0,
onPageClick : function(pageNumber) {
jQuery("#target-content").html('loading...');
jQuery("#target-content").load("pagination.php?page=" + pageNumber);
}
});
});
</script>
I reset the form
Please help me
I hope I was clear
I also leave you an email, I am willing to pay for help
IlfreeIF#gmail.com
This is exactly what AJAX is for (AJAX can do the same .load() function can, but with more configurability):
http://www.seguetech.com/ajax-technology/
jQuery Ajax POST example with PHP

Automatic submit of form on page load cause infinite loop

i'm using a Filter in which i use the Form..When a user a land on the list page it should automatically submit the form so user can get values only he want to see. i have tried a lot of things like jquery JS and using snippet in body but none of them is working. For the following code the form keep on submitting.
<div class="container shop-filter">
<div class="filter">
<form action="" method="POST" enctype="multipart-form-data" id="city-filter" name="cit-filter">
<select name="filter" id="select">
<option value="all">All city</option>
<?php
$sql="SELECT * FROM tcity";
$connect= mysqli_query($conn, $sql) or die ("Failed To Connect.");
while($rows= mysqli_fetch_array($connect, MYSQLI_ASSOC)){ ?>
<option value= "<?php echo $rows['c_id']?>" id="optin_val" <?php echo (!empty($_COOKIE['dropdown']) && $_COOKIE['dropdown'] == $rows['c_id'] ? 'selected' : ''); ?>><?php echo $rows['city_nm'];?></option>
<?php }
?>
</select>
<input type="submit" name="submitt" id="submitt" value="filter" class="btn .btn-default">
</form>
</div>
<div class="view">
<i class="fa fa-th fa-lg" aria-hidden="true"></i><span id="grid-view"> Grid</span>
<i class="fa fa-th-list fa-lg" aria-hidden="true"></i><span id="list-view"> list</span>
</div>
<hr id="hr-1" style="width:100%">
</div>
<div class="container blocks" id="content">
<?php
//Grab the variable sent through link by sub_category.php
//session_start();
$subcategory_id='';
$subcategory_id= $_GET['sub_id'];
$_SESSION['sub'] = $subcategory_id;
$row_count = 0;
if(isset($_POST['submitt'])){
$city_id=$_POST['filter'];
if($city_id == 'all'){
$sql="SELECT * FROM tadd WHERE sub_id = '$subcategory_id' ORDER BY add_nm";
}else{
$sql="SELECT * FROM tadd WHERE sub_id = '$subcategory_id' AND c_id = '$city_id' ORDER BY add_nm";
}
}else{
$sql="SELECT * FROM tadd WHERE sub_id = '$subcategory_id' ORDER BY add_nm";
}
//$sql="SELECT * FROM tadd WHERE sub_id = '$subcategory_id' AND c_id = '$city_id'";
$conection = mysqli_query($conn, $sql);
while ($rows = mysqli_fetch_array($conection, MYSQLI_ASSOC)){
$name = $rows['add_nm'];
$add_id = $rows['add_id'];
//get the join date and Expiry date to hide Expired Contents
$current_date = strtotime(date('Y-m-d'));
$exp = strtotime($rows['exp_dt']);
$row_count = mysqli_num_rows($conection);
//get Images
//$shop_image = trim($add_id.'.jpg');
?>
<!-- Do Not Show Expired Contents -->
<?php if( $current_date <= $exp ) {?>
<div class="dialog">
<div class="shop_img">
<img src="../image/shops/1.jpg" alt ="<?php echo $name;?>" >
</div>
<hr id="hr">
<div class="shop_name">
<?php echo strtoupper($name);?>
</div>
<a href="detail.php?add=<?php echo $add_id;?>"><div class="address">
<span id="1">ADDRESS</span><span id="2"><i class="fa fa-arrow-right" aria-hidden="true"></i></i></span>
</div></a>
</div>
<?php
}
}
if( $row_count == 0 ){
echo '<div class ="msg">Sorry! No Entries Found.</div>';
}
?>
</div>
</body>
<footer>
<?php
include("../footer.html");
?>
</footer>
<script>
$(document).ready(function(){
$("#city-filter").submit();
})
</script>
As i shown in image when user comes to this page it has to show only success classes. But it is showin all...when i hot filter it'll show currect.so i want to cancel hiting submit manually and auto submit the form
You could put it inside a condition to check if there are some dialog divs:
$(document).ready(function(){
if($('.dialog').length === 0 ){ // check the length of dialog div if 0
$("#city-filter")[0].submit(); // then only submit the form
}
})
Instead use the native .submit() event on the form.

how to apply infinte scroll to this costom pagination page

I'm using this page to list all the users to a page. I'm listing it using custom pagination, now I have to display using infinite scroll using ajax or jquery . googled/stackoverflowed lots of solutions nothings seems to work with this custom pagination in the page
$paging_Obj = new Pagination();
$perPagerecord = 6;
$page = $this->getRequest()->getParam('page');
if($page){
$start = ($page - 1) * $perPagerecord;
}else{
$start = 0;
}
if($page == 0){
$page = 1;
}
$prev = $page - 1;
$next = $page + 1;
$limitCond = "LIMIT $start, $perPagerecord";
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
//echo $artistTotalQuery = "SELECT * FROM marketplace_userdata WHERE mageuserid IN (SELECT userid FROM marketplace_product GROUP BY userid) AND partnerstatus = 'Seller' AND wantpartner = '1' ORDER BY autoid ASC";die;
$artistTotalQuery = "SELECT mu.*,cev.value as first_name,cev1.value as last_name FROM marketplace_userdata as mu LEFT JOIN customer_entity_varchar AS cev ON (cev.entity_id = mu.mageuserid) AND (cev.attribute_id = '5') LEFT JOIN customer_entity_varchar AS cev1 ON (cev1.entity_id = mu.mageuserid) AND (cev1.attribute_id = '7') WHERE mu.mageuserid IN (SELECT userid FROM marketplace_product GROUP BY userid) AND mu.partnerstatus = 'Seller' AND mu.wantpartner = '1'
GROUP BY cev.entity_id ORDER BY cev1.value ASC";
$sellerlist_total = $readConnection->fetchAll($artistTotalQuery);
$count = count($sellerlist_total);
$artistQuery = "SELECT mu.*,cev.value as first_name,cev1.value as last_name FROM marketplace_userdata as mu LEFT JOIN customer_entity_varchar AS cev ON (cev.entity_id = mu.mageuserid) AND (cev.attribute_id = '5') LEFT JOIN customer_entity_varchar AS cev1 ON (cev1.entity_id = mu.mageuserid) AND (cev1.attribute_id = '7') WHERE mu.mageuserid IN (SELECT userid FROM marketplace_product GROUP BY userid) AND mu.partnerstatus = 'Seller' AND mu.wantpartner = '1' GROUP BY cev.entity_id ORDER BY cev1.value ASC $limitCond";
$sellerlist = $readConnection->fetchAll($artistQuery);
if($count>0){
?>
<?php
$categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter();
$allcatid = array();
$k=0;
foreach ($categories as $c) {
$allcatid[$k] = $c->getId();
$k++;
}
$finalcat=array_shift($allcatid);
?>
<div class="div_Row">
<?php
$pagination = "";
$nextDisplayPagesLimit = 3;
$callPaging = $paging_Obj->Pagination($pagination,$count,$nextDisplayPagesLimit,$perPagerecord,$page,$next,$prev,$redirectUrl);
echo $callPaging;
?>
</div>
</div>
</div>
<div class="div_Row">
<?php
$m = 1;
foreach($sellerlist as $seller){
$customerid=$seller['mageuserid'];
$customer=Mage::getModel('customer/customer')->load($customerid);
/*********User Total Products and get last add product image Start************/
$query = "SELECT count(*) as total, max(mageproductid) as lastProduct_id FROM marketplace_product WHERE userid = $customerid";
$Product_result = $readConnection->fetchAll($query);
$totalProducts = $Product_result[0]['total'];
if(isset($totalProducts) && $totalProducts > 0){
$product_id = $Product_result[0]['lastProduct_id'];
$productDetails = Mage::getModel('catalog/product')->load($product_id);
$height = $this->helper('catalog/image')->init($productDetails, 'small_image')->getOriginalHeight();
$width = $this->helper('catalog/image')->init($productDetails, 'small_image')->getOriginalWidth();
$Product_image = $this->helper('catalog/image')->init($productDetails, 'small_image');
}else{
$Product_image = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$APHolder;
//$profileURLArtist = Mage::getUrl()."marketplace/seller/profile/".$seller['profileurl']."/list";
$profileURLArtist = Mage::getUrl()."artist/".$seller['profileurl'];
?>
<div class="Artist_list_box span4">
<div class="Artist_main_img">
<a class="product-image-listing" href="<?php echo $profileURLArtist; ?>">
<img alt="<?php echo $customer_name; ?>" title="" src="<?php echo $Product_image;?>" style="width:<?php echo $widthRe."px";?>;max-width:<?php echo $widthRe."px";?>;margin-top:<?php echo $imageHeightDiff."px";?>; margin-left:<?php echo $imageWidthDiff."px";?>;">
</a>
</div>
<div class="List_inner_box">
<!-- <div class="List_them_bg">
</div>-->
<div class="List_inner_text">
<div class="list_Name_title">
<?php echo $customer_name; ?>
<?php if($city!='' && $country!=''){?>
<span> <?php echo $city.", ".$country;?></span>
<?php }?>
<div class="pieces"><p style="margin-bottom:0;"><?php echo $totalProducts?> Artworks</p></div>
</div>
<div class="List_them">
<a href="<?php echo $profileURLArtist; ?>">
<img style="height:50px;width:50px;" alt="<?php echo $customer_name; ?>" src="<?php echo $logo;?>">
</a>
</div>
<div class="list_text"><?php //echo $customer_desc;?></div>
</div>
</div>
</div>
<?php if($m % 4 == 0){?>
<div style="clear:both"></div>
<?php } $m++;?>
<?php
} ?>
</div>
<div class="div_Row">
<div class="pager">
<?php
$pagination = "";
$nextDisplayPagesLimit = 3;
$callPaging = $paging_Obj->Pagination($pagination,$count,$nextDisplayPagesLimit,$perPagerecord,$page,$next,$prev,$redirectUrl);
echo $callPaging;
?>
</div>
</div>
<?php
have you tried Paul Irishs jquery plugin?
https://github.com/paulirish/infinite-scroll
Should work

Categories