Forum Moderators: coopster

Message Too Old, No Replies

Search result to Next page...

         

AlexLee

10:23 am on Jan 28, 2005 (gmt 0)

10+ Year Member



Hi, how do I do those search results with display limit?

Like displaying 20 results per page and user have to click NEXT to view next 20 results. And of course a BACK link too...

dreamcatcher

12:07 pm on Jan 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi AlexLee,

Its called pagination. If you do a search on Google you should find some tutorials. I think there is one at Codewalkers. Or maybe it was PHP Freaks. Another thing you can try is to download a script that has page numbers (such as a guestbook script) and take a look at the code.

Its not actually too hard. You`ll need two queries, one for the total count of rows, the second with a start limit and an end limit. A little calculation using some mathematical operands and you are good to go.

Good luck.

Zipper

8:00 pm on Jan 28, 2005 (gmt 0)

10+ Year Member



[phpfreaks.com...]
hard to forget it ha? great tute!

AlexLee

8:11 am on Jan 30, 2005 (gmt 0)

10+ Year Member



Hey thanks guys!

AlexLee

1:16 pm on Jan 30, 2005 (gmt 0)

10+ Year Member



After searching a lot of codes and testing them. I found out that I like this one. But only some parts seems to be functional.

The page links can be printed out(finally). However there is the "Undefined variable: PHP_SELF" error.

When I changed the " to '. The error is gone. But now they were linked as [localhost:81...] How do I solve this problem? And when I manually change the $PHP_SELF to index.php in the address bar to see if it will work, it does not.

[edited by: ergophobe at 5:08 pm (utc) on Jan. 31, 2005]
[edit reason] code dumped snipped - copyright issues [/edit]

Zipper

5:41 pm on Jan 30, 2005 (gmt 0)

10+ Year Member



try $_SERVER['PHP_SELF'] instead of "$PHP_SELF"

AlexLee

11:59 pm on Jan 30, 2005 (gmt 0)

10+ Year Member



Thanks, it is now linking the correct pages.

But I am still having the problem of it staying on the same page. It does not go to Next page or to the page I clicked.

Zipper

12:48 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



add this to the begining of the script,

$page = $_GET['page'];

AlexLee

3:41 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



Oh thank you!
I am so happy...
Tried so many codes on the internet but none seems to work. And I had no idea how to edit them. Now it finally work thanks to you.

CHEERS!