I am trying to get some results to show up on multiple pages, but its not working...
What am I missing here..... I want it to look like:
[Prev] 1 2 3 [NEXT]
Thanks,
-JRW
PHP Code:
<?php
require("./global.php");
eval("\$header = \"".gettemplate("header",1,0)."\";");;
eval("\$footer = \"".gettemplate("footer",1,0)."\";");
if ($manufacturer_id) {
$manufacturer = $DB_site->query_first("SELECT name, logo, website, salesemail, techemail, usaddress, city, state, zipcode, phonenumber FROM manufacturers WHERE manufacturer_id = '$manufacturer_id'");
extract($manufacturer);
$color = '{firstaltcolor}';
eval("\$manufacturerbits .= \"".gettemplate("manufacturerbits",1,0)."\";");
} else {
$manufacturers = $DB_site->query("SELECT manufacturer_id, name, website FROM manufacturers ORDER BY name ASC");
if (!$DB_site->num_rows($manufacturers)) {
print eval("\$manufacturerbits .= \"".gettemplate("manufacturer_error",1,0)."\";");
} else {
$limit=20; // rows to return
$numresults=DB_site->query("select * from manufacturers ORDER BY name ASC");
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=1;
}
// get results
$result=$DB_site->query("SELECT manufacturer_id, name,website FROM manufacturers ORDER BY name ASC LIMIT $offset,$limit");
// now you can display the results returned
while ($data=mysql_fetch_array($result)) {
// include code to display results as you see fit
extract($data);
$color = ($num++ % 2) ? '#DFDFDF' : '#F1F1F1';
eval("\$manufacturerbits .= \"".gettemplate("manufacturerbit",1,0)."\";");
}
// next we need to do the links to other results
if ($offset==1) { // bypass PREV link if offset is 0
$prevoffset=$offset-20;
$prev = "<a href=\"$PHP_SELF?offset=$prevoffset\">PREV</a> \n";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
eval("\$number .= \"".gettemplate("number",1,0)."\";");
}
}
// check to see if last page
if (!(($offset/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$newoffset=$offset+$limit;
$next = "<a href=\"$PHP_SELF?offset=$newoffset\">NEXT</a><p>\n";
}
}
}
eval("dooutput(\"".gettemplate("manufacturer")."\");");
?>
[Prev] 1 2 3 [NEXT]
Thanks,
-JRW
Comment