tags:

views:

171

answers:

2

hi, here is the script im using http://www.goodphptutorials.com/out/Simple_PHP_MySQL_Pagination

this is the code i put on the page (excluding all other code)

//pagination
$page = 1;

// how many records per page
$size = 10;

// we get the current page from $_GET
if (isset($_GET['page'])){
    $page = (int) $_GET['page'];
}

// create the pagination class
$pagination = new Pagination();
$pagination->setLink("listing.php?page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);

my query looks like this

$query = mysql_query("select * from tbl_listing ".$pagination->getLimitSql()) or die(mysql_error());

the error im getting is this

Notice: Undefined variable: total_records in D:\wamp\www\lolallday\admin\listing.php on line 25

line 25 is this: $pagination->setTotalRecords($total_records);

and the pagination links dont show. anyone know what can be the problem? i cant figure it out.

thanks

+1  A: 

You got this error because $total_records was not initialized. Initialize it or lower error_reporting.

Edit: by initializing i mean that it's value was never assigned (tutorial seems a bit incomplete)

Alekc
+3  A: 

$total_records needs to be assigned the total count of records in your table. Perform a 'select count(*) from x' query on your table to get the total number of records, and initialize it to that value.

karim79