pagination problems...

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 10, 2012   (RSS)

Im having some pagination problems, could someone help me out and figure out where i went wrong?

the page is shawnpatoka.com/list.php

the code is...

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/nfs/c06/h05/mnt/94791/domains/shawnpatoka.com/html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }


list($participating, $barMetaData) = getRecords(array(
'tableName' => 'participating_bars',
'loadUploads' => true,
'allowSearch' => false,
'where' => "participating_bar = '1'"
));

list($notParticipating, $barMetaData) = getRecords(array(
'tableName' => 'participating_bars',
'perPage' => '5',
'loadUploads' => true,
'allowSearch' => false,
'where' => "participating_bar = '0'"
));

?>


and the pagination coding is...

<?php if ($notParticipating['prevPage']): ?>
<a href="<?php echo $notParticipating['prevPageLink'] ?>">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>

- page <?php echo $notParticipating['page'] ?> of <?php echo $notParticipating['totalPages'] ?> -

<?php if ($notParticipating['nextPage']): ?>
<a href="<?php echo $notParticipating['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?php endif ?>

Re: [shawnpatoka] pagination problems...

Hi,

I think I can see what the problem is. The meta data variable is used to store information for pagination, your example calls the $notParticipating variable and not the $barMetaData variable in your pagination code.

Something like this should work:

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/nfs/c06/h05/mnt/94791/domains/shawnpatoka.com/html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }


list($participating, $barMetaData) = getRecords(array(
'tableName' => 'participating_bars',
'loadUploads' => true,
'allowSearch' => false,
'where' => "participating_bar = '1'"
));

list($notParticipating, $notbarMetaData) = getRecords(array(
'tableName' => 'participating_bars',
'perPage' => '5',
'loadUploads' => true,
'allowSearch' => false,
'where' => "participating_bar = '0'"
));


And....

<?php if ($notbarMetaData['prevPage']): ?>
<a href="<?php echo $notbarMetaData['prevPageLink'] ?>">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>

- page <?php echo $notbarMetaData['page'] ?> of <?php echo $notbarMetaData['totalPages'] ?> -

<?php if ($notbarMetaData['nextPage']): ?>
<a href="<?php echo $notbarMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?php endif ?>


Thanks!
Greg Thomas







PHP Programmer - interactivetools.com