View Full Version : Pagination help
misterfade
30 Jan 2006, 17:15
I'm trying to query the vbulletin database on a custom table, and paginate the results. From the code I have, for some reason it only returns 40 total results. I'm having trouble with the $total_results part, can anyone help me out?
Thanks.
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
misterfade
04 Mar 2006, 21:23
No one??
Princeton
04 Mar 2006, 22:21
this should get you in the right direction: NOTE: change the QUERY as I changed it to do a test
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
misterfade
05 Mar 2006, 15:46
Thanks for the response. I tried your code and it looks like it's working fine.
Can you explain what this part is doing?
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
I don't understand those lines, is that what I have to use with vbulletin? Or is this just for testing purposes?
Thanks again!
Princeton
05 Mar 2006, 16:05
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
you should get into the habit of "cleaning" any $_GET, $_REQUEST, and $_POST data .... the above is a vb function that cleans/converts data that will be used
if you study the vb files or any product/plugin found here (vb.org) you will find the above line more frequently
This:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
does the same thing as
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
The ?: operator is used as a shorthand replacement for the if-then-else conditional statement; the general form is condition ? op1 : op2. If condition is true, the statement evaluates as op1; otherwise, it evaluates as op2.
misterfade
05 Mar 2006, 16:10
Ok thanks for the tip!
I was just trying the code again, and for some reason it's only showing a certain amount of rows. The table that I'm querying should be showing 65 results (rows), but it always stops at 40. I have it set for 10 results per page, and it keeps showing only 4 pages, so 40 rows. I ran my query in PHPMyAdmin and it works fine, so it's got to be the pagination with vbulletin. Any ideas as to why that would be happening?
Even the query from your code, it seems to work, but it shows 5 results per page, 6 pages total. That doesn't seem right.
Princeton
05 Mar 2006, 16:12
the code was meant to be a starting point for you
misterfade
05 Mar 2006, 16:14
Yeah I know but that's the main problem I was having originally, only showing a certain amount of results. I was just wondering if you had an idea as to why it would be doing that.
Thanks though.
Princeton
05 Mar 2006, 16:55
I edited the above code.
try
$from = ($vbulletin->GPC['page'] - 1) * $max_results;
misterfade
05 Mar 2006, 18:10
The new code you posted works great except for one thing. This works:
$from = (($page * $max_results) - $max_results);
Not this one:
$from = ($vbulletin->GPC['page'] - 1) * $max_results;
Thanks for all the help! So glad I got this working.
vBulletin® v3.6.12, Copyright ©2000-2009, Jelsoft Enterprises Ltd.