Please help a beginner who hasn't got much more hair to pull out.
I searched lots for an answer, tried my own ideas and now feel lost.
I having problems with a pagination script and implode in the same script.
I've a form with checkboxes:
<input type="checkbox" name="lid[]" value="$lid" >
That gets submitted to a result script. All seems honky dorkery (first set of results is sweet) until I click on the next page link.
This is the main part of the result script:
$pagelimit = "3";
$strSQL =mysql_query("SELECT * FROM table1, table2, table3, type WHERE lid IN ('" . implode("','", $_POST['lid']) . "') and variable2 >=$variable2 ORDER BY variable2 DESC");
$totalrows = mysql_num_rows($strSQL);
$pagenums = ceil ($totalrows/$pagelimit);
// if no value for page, page = 1
if ($_POST["page"] == ''){
$page = '1';
}
// create a start value
$start = ($page-1) * $pagelimit;
// blank matches found
echo "<b>" . $totalrows . " matches found</b><br>\n";
// Showing Results 1 to 1 (or if you're page limit were 5) 1 to 5, etc.
$starting_no = $start + 1;
if ($totalrows - $start < $pagelimit) {
$end_count = $totalrows;
} elseif ($totalrows - $start >= $pagelimit) {
$end_count = $start + $pagelimit;
}
echo "Results $starting_no to $end_count shown.<br>\n";
// create dynamic next, previous, and page links
if ($totalrows - $end_count > $pagelimit) {
$var2 = $pagelimit;
} elseif ($totalrows - $end_count <= $pagelimit) {
$var2 = $totalrows - $end_count;
}
$space = " ";
// previous link
if ($_POST["page"] > 1) {
echo "« <a href='$PHP_SELF?page=".($page-1)."' class=main>Previous" . $space . $pagelimit . "</a>" . $space . $space . "";
}
// dynamic page number links
for ($i=1; $i<=$pagenums; $i++) {
if ($i!= $_POST["page"]) {
echo " <a href='$PHP_SELF?page=$i' class=main>$i</a>";
}
else {
echo " <b>$i</b>";
}
}
// next link
if ($_POST["page"] < $pagenums) {
echo "" . $space . $space . $space . $space . " <a href='$PHP_SELF?page=".($page+1)."' class=main>Next " . $var2 . "</a> »";
}
// then display the results
$result =mysql_query("SELECT * FROM table1, table2, table3, type WHERE lid IN ('" . implode("','", $_POST['lid']) . "') and variable2 >=$variable2 ORDER BY variable2 DESC, LIMIT $start,$pagelimit");
//end of example
Trouble is I get this:
Warning: Bad arguments to implode()