pagnation
Posted: Sat Feb 23, 2008 2:21 am
I want to add pagnation to this but have no clue on how to do it
Please help me if you can..
Please help me if you can..
Code: Select all
<?php
//I want to add pagnation to this but have no clue
//Please help if you can
//Not sure about this function on what needs to be edited as far as results per page
//I am sure that in the $ret line that the page variable needs to be a varible as to what page is what were on
$q = htmlentities($_GET['q']);
function searchFeedResults($q, $results, $tID, $pID)
{
$res = array();
$ret=file("http://www.searchfeed.com/rd/feed/TextFeed.jsp?trackID=".$tID."&excID=&pID=".$pID."&cat=".urlencode($_GET['q'])."&nl=".$results."&page=1&ip=".$_SERVER["REMOTE_ADDR"]);
if ( count($ret) == 0 ) return $res;
for ( $i=0;$i<count($ret);$i=$i+5 )
{
$j = $i;
for ( $j=$i;$j<($i+4);$j++)
{
$a = explode('|',$ret[$j]);
$tmp[] = $a[2];
}
$res [] = $tmp;
unset($tmp);
}
return $res;
}
$myTid = 'changeme';
$myPid = 'changeme';
echo '
<p>
Search :
<form method="get" action="'.$_SERVER['PHP_SELF'].'" />
<input type="text" name="q" value="'.$_GET['q'].'" />
<input type="submit" value="Go" />
</form>
</p>';
if ( !empty($_GET['q'])){
$results = searchFeedResults($_GET['q'], 5, $myTid, $myPid );//5 is how many results per page
if ( $results ){
foreach ( $results as $rec ){
echo '
<p>
<a href="'.$rec[2].'" onmouseover="window.status=\'http://'.$rec[1].'\'; return true"
onmouseout="window.status=\' \'; return true">'.$rec[0].'</a><br />
'.$rec[3].'<br />
<small>'.$rec[1].'</small>
</p>';
}
//need to add pagnation here
}else{
echo 'No results for '.$_GET['q'].'<br /><br />';
}
}
?>