gbirke/jquery_pagination — Issue #18: help - only showing one item with ajax load call to a php file
Author: pcout
Created: 2011-10-23 04:03:41+00:00
State: open

Hi,

I´m having an issue with this (great by the way) plugin.
I´m calling a PHP file in the load method, like this:

$('#hiddenresult').load('filename.php',null,initPagination);

in that PHP file i´m using standard MySql and PHP, like this.
filename.php
/* ----------------------------------------------------------------------------------------------------------------------------------- */
$SQL = "SELECT.............."
$result = mysql_query($SQL);
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_object($result)) {

// my items

}
}
/* ----------------------------------------------------------------------------------------------------------------------------------- */

it all goes well except from the fact that it only displays one record - the very first one.
The pagination is fine. it calculates the page numbers just fine.

What is going on ? What am i doing wrong ?.
Can you help me please ?

This is the javascript code i use on the index page.
index.php
/* ----------------------------------------------------------------------------------------------------------------------------------- */
function pageselectCallback(page_index, jq){
var new_content = $("#hiddenresult div.result:eq("+page_index+")").clone();
$("#Searchresult").empty().append(new_content);
return false;
}
function initPagination() {
var num_entries = $("#hiddenresult div.result").length;
$("#Pagination").pagination(num_entries, {
num_edge_entries: 1,
num_display_entries: 7,
callback: pageselectCallback,
items_per_page: 4,
current_page: 0,
next_text: "Próximo",
next_show_always: false,
prev_text: "Anterior",
prev_show_always: true,
ellipse_text: "...",
load_first_page: true,
show_if_single_page:false
});
}
$(document).ready(function(){
$('#hiddenresult').load('filename.php',null,initPagination);
});
/* ----------------------------------------------------------------------------------------------------------------------------------- */