Max Albert
The first link was very helpful... the code just needed a little tinkering and it works perfectly for me.
Thank you very much!!!
-JRW
Announcement
Collapse
No announcement yet.
MySQL results on multiple pages
Collapse
X
-
Well, thanks for the links... I'll be sure to check them out. I did search using a bunch of different terms and didnt come up with those links.
Thanks again,
-JRW
Leave a comment:
-
MySQL results on multiple pages
I am trying to get some results to show up on multiple pages, but its not working...
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,
-JRWTags: None
Related Topics
Collapse
-
I'm looking in ACP the option where you can set the link below in the forumdisplay for the other pages. Here in the forum it currently looks like this, see Appendix 1. 1 - 2 - 3 - 4 - 5 - 6 - 11 - 18...
-
Channel: Support Issues & Questions
Wed 18 Apr '18, 10:44pm -
Leave a comment: