Hello there,
I have a website that allows to search within a database of mine.
The results are displayed in a table, and I would like to split the results to pages so it’ll be 10 results per page.
Before I display the code here’s an explanation of it:
$result2 is my sql query (assume that it’s valid).
$perpage is initially 10 (defined by me).
$x is a value of a dropdown box from a form in another page.
$y is a value of a textarea from the same form.
$z as $x only from another dropdown box (same form).
$r and $t as $y only from other textareas (same form).
$s is an ARRAY of checked checkboxed from the same form.
Here’s the code part responsible of the pages spliting:
[CODE]$nump = mysql_num_rows($result2);
$nump = $nump / $perpage;
if(intval($nump) != $nump)
$nump = intval($nump) + 1;
for($I = 1; $I<= $nump; $I++)
{
if($page != $I) {
if (count($s) > 0)
echo “<A HREF=$PHP_SELF?page=$I&x=$x&y=$y&z=$z&t=$t&r=$r&s=$s>$I</A>”;
else
echo “<A HREF=$PHP_SELF?page=$I&x=$x&y=$y&z=$z&t=$t&r=$r&s=’ ‘>$I</A>”;
}
else
echo $I;
if($I != $nump)
echo ” – “;
}
echo “<br /><br />”;
$lim1 = ($page – 1) * $perpage;
$query2 .= “LIMIT $lim1,$perpage “;
$result2 = mysql_query($query2);
What I get is this:
In the first page, everything’s ok and it displayed the first 10 results. BUT, it the second one, it gives me an error that the query is not valid and it gives me a message as if no results found.
I’ll be happy to recieve some help.
Thanks in advance