Pagenation Set up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a problem with this search script as it return all the information in the database when I search for any term,I  set the pagenation to a limit of 10, but I can't firgure out why the set limit is not working. Can any one with an eagle eyes spot the error please?
 
Gab

<?php
if(!empty($_GET[Submit]))
 {
include("databaseconfig.php");
$term=$_GET['term'];
if($term == "")
{
 echo "<p>Please enter a search...</p> ";
 exit;
}
else
{
echo "Your Search Result<br>";
"<p>";
}
}
$pagenum = 1;
{$pagenum=$_POST[page];}
$rowsperpage = 10;
$offset=($pagenum-1)*$rowsperpage;

$numrows=$row[numrows];
$maxPage=ceil($numrows/$rowsperpage);
$sql=mysql_query("select *   from selling where product like '$trimmed%' or description like '$trimmed%' or price like '$trimmed%' or info like '$trimmed%' or contactseller like '$trimmed%' order by id DESC ");
if (mysql_num_rows($sql)==0)
echo " No result";
else
{
while ($result=mysql_fetch_array($sql))
{
$id=$result[id];
$product=$result[product];
$description=$result[description];
echo "<a href=fullsearch.php?id=$id>".$result[product]."</a><br>";
echo "$result[description]";
echo "<p>";
}
 
$pageno=$pagenum+1;
    $prev=$pagenum-1;
    $penultimate=$maxPage-1;
if($pagenum==$maxPage and $maxPage>1)
{
echo "<center>";
echo "[ <a href=search.php?page=$prev>PREVIOUS PAGE</a> ]";
echo "        ";
echo "[ <a href=search.php?page=1>FIRST PAGE</a> ]";
echo "</center>";
}
elseif($pagenum<$maxPage and $pagenum==1)
{
echo "<center>";
echo "[ <a href=search.php?page=$pageno>NEXT PAGE</a>]";
echo "        ";
echo "[ <a href=search.php?page=$maxPage>LAST PAGE</a>]";
echo "</center>";
}
elseif($pagenum<$maxPage and $pagenum>1) 
{
echo "<center>";
echo "[ <a href=search.php?page=1>FIRST PAGE</a> ]";
echo "        ";
echo "[ <a href=search.php?page=$pageno>NEXT PAGE</a> ]";
echo "        ";
echo "[ <a href=search.php?page=$prev>PREVIOUS PAGE</a> ]";
echo "        ";
echo "[ <a href=search.php?page=$maxPage>LAST PAGE</a> ]";
echo "</center>";
}
else 
echo "<center>This is the only page</center>";
echo "<center>Showing page $pagenum  of $maxPage</center>";
 
}

?> 
 


      

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux