Help with search results on multiple pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mthierfelder
Forum Newbie
Posts: 12
Joined: Mon Apr 10, 2006 3:18 pm

Help with search results on multiple pages

Post by mthierfelder »

I am working on a search engine for a client, and for the most part it is working great. The part I need help or suggestions on is with the search results. Right now only the top 10 results are retreived, and displayed on one page. I would like it to retreive ALL results for a given search, display the first 10 on page 1, then subsequent results on pages 2, 3, etc.

Here is the query that is currently being called for the search results:

Code: Select all

$q1 = "select * from yellow_agents, yellow_priority, yellow_categories where yellow_agents.CategoryID = yellow_categories.CategoryID and yellow_agents.PriorityLevel = yellow_priority.PriorityLevel and yellow_agents.AccountStatus = 'active' order by visits desc limit 0,9 ";

$r1 = mysql_query($q1) or die(mysql_error());
$lrows = mysql_num_rows($r1);
"yellow" refers to this script's name because it is a yellow pages directory for businesses, there are different categories (electricians, contractors, etc.), and there are different priority levels (standard, gold, platinum, etc). Any help is appreciated, I don't know where to even start.

Oh, you can view the live script here: http://www.nwbuildnet.com/stores/builders/

Thanks in advance!
Mike
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

There is Pagination code in the Code Snippets section. I have some Pagination code with examples you can download here.
(#10850)
mthierfelder
Forum Newbie
Posts: 12
Joined: Mon Apr 10, 2006 3:18 pm

Post by mthierfelder »

I'm pretty new at this, so I am not really sure where to even start...maybe over my head. Would you think this would be fairly complicated to figure out?

Mike
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

We won't know until you try out the code in the Code Snippets section or the download I provided a link to -- and tell us.
(#10850)
Post Reply