php xml pagination issues missing one result



the following code i set to have results from xml put into pagination, it is working for the most part, but it is missing a line each time.


so i have it set at 7 it only shows 6 results per page here is my Code:



$thispage= $_SERVER['PHP_SELF'];
$startPage = $_GET['page'];
$perPage =7;
$currentRecord = 0;

/ Start XML Parsing
$dom = new DOMDocument();
$dom->load('Playlist.xml');

$xmlPath = new DOMXPath($dom);
$arrNodes = $xmlPath->query('//channels/channel');

foreach($arrNodes as $item){

$currentRecord += 1;
if($currentRecord > ($startPage * $perPage) && $currentRecord < ($startPage * $perPage + $perPage)){

// Get Name
$id=$item->getAttribute('id');

// lets limit title
$string=$item->getAttribute('name');
$finTitle = (strlen($string) > 55) ? substr($string,0,52).'...' : $string;

// lets limit category
$cat=$item->getAttribute('category');
$category= (strlen($cat) > 20) ? substr($cat,0,17).'...' : $cat;
// now we have the URL to pass on
$vidUrl=$item->getAttribute('url');

if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
else{$bgcolor='#f1f1f1';}

echo "<tr >";
echo "<td bgcolor=$bgcolor id='title ' align=center>&nbsp;<font face='Verdana' size='2'>$id</font></td>";
echo "<td bgcolor=$bgcolor id='title' align=center>&nbsp;<font face='Verdana' size='2'>$finTitle</font></td>";
echo "<td bgcolor=$bgcolor id='title' align=center>&nbsp;<font face='Verdana' size='2'>$category</a></font></td>";
echo "</tr>";
}
}


Thanks i am sure i am just missing something somewhere at first i thought it was here : $currentRecord += 1; but if i change that to just 1 or 0 it will not show any results


No comments:

Post a Comment