Forum Moderators: coopster & phranque

Message Too Old, No Replies

Searching and Displaying Results Theory

Optimising Process

         

ukgimp

3:15 pm on May 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know this has probably been covered before so apologies before I even begin.

Say I have a complex sql query for multiple words and across multiple fields. Imagine I have 100 results that match and I wish to display only 25 per page. Would the following be the best approach?

Perform search
Count records
Number of pages = count/25
Extract first 25 results

Now I am trying to get my head round this. Surely it is not the best idea to have the whole result set in an array. Would it be better to use LIMITs to only get the ones the user is after from the DB as and when required. I know this means more db call but that is the theory side I am after.

Any advice or pointers appreciated.

Cheers

Birdman

5:37 pm on May 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello, check this thread for some insight: Help with next/prev theory [webmasterworld.com]

willybfriendly

5:42 pm on May 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just grappled with this problem myself. My solution was to use limit $llimit, $ulimit. Then in the "more results" link I passed the ulimit back to the query, i.e.

<A HREF"query script?limit=$ul">More Results</A>

goes to

$llimit = $ul;
$ulimit = $llimit+25;

$sql = "query string LIMIT $llimit, $ulimit"

Oversimplified here of course, but you get the idea. It worked for me.

WBF