Can someone please help me with Pagination & Multiple Select Opion form.
I have the following script got it from here.
The multiple select search works, but the pagination does not work.
The error I get is posted at the bottom.
I really appreciate the help.
<?
require ("inc/global.php");
$limit = 5;
if ( !$page or $page < 0 )
{
$page = 0;
}
$loc = implode("','",$_POST[location]);
$sql = "SELECT * FROM jobs WHERE location IN('$loc')";
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
if ($rows == 0)
{
echo("No results found matching your query. ");
exit();
}
else
{
$pages = intval($rows/$limit);
if ($rows%$limit)
{
$pages++;
}
$current = intval($page/$limit) + 1;
if ( $pages < 1 )
{
$total = 1;
}
else
{
$total = $pages;
}
$first = $page + 1;
if (!((($page + $limit) / $limit) >= $pages) && $pages != 1)
{
$last = $page + $limit;
}
else
{
$last = $rows;
}
$sql = "SELECT * FROM jobs WHERE location IN('$loc') ORDER BY title ASC LIMIT $page, $limit";
$result = mysql_query($sql);
if (mysql_num_rows($result) != 0)
{
print "
<table width=600 cellpadding=5 cellspacing=1 border=0>
<tr bgcolor=#ffffce>
<td width=50>ID</td>
<td width=100>Date</td>
<td width=200>Job Title</td>
<td width=150>Company</td>
<td width=100>Location</td>
</tr>";
while ($data = mysql_fetch_array($result))
{
$date = strftime ("%m-%d-%Y", $data[date]);
$bgcolor = ($i++ % 2) ? '#f0f0f0' : '#c0c0c0';
print "<tr bgcolor='$bgcolor'>
<td>$data[id]</td>
<td>$date</td><td><a href=details.php?id=$data[id]>$data[title]</a></td><td>$data[company]</td><td>$data[location]</td></tr>";
}
print "</table>";
}
if ($page != 0)
{
$back_page = $page - $limit;
echo("<a href=\"search.php?loc=$loc&page=$back_page&limit=$limit\"><<</a> \n");
}
for ($i=1; $i <= $pages; $i++)
{
$ppage = $limit*($i - 1);
if ($ppage == $page)
{
echo("<b>$i</b> \n");
}
else
{
echo("<a href=\"search.php?loc=$loc&page=$ppage&limit=$limit\">$i</a> \n");
}
}
if (!((($page+$limit) / $limit) >= $pages) && $pages != 1)
{
$next_page = $page + $limit;
echo(" <a href=\"search.php?loc=$loc&page=$next_page&limit=$limit\">>></a>\n");
}
}
?>
I'm getting the following error.
Warning: implode(): Bad arguments. in /home/computem/public_html/search.php on line 11
No results found matching your query.
I get this serror, when I click on Next, Back or the different page number links.