Welcome to WebmasterWorld Guest from 54.147.10.72

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Search Results and Output buffering

     

tongpo

6:39 pm on Feb 5, 2005 (gmt 0)

10+ Year Member



I am currently working on a search results page. I am pretty new to PHP and I have run into a problem I just cannot work out.

My results page displays a set number of results per page and allows users to jump to any page they want, aswell as prev, next etc

This part is working fine.

I am now trying to improve the script by highlighting search terms that appear on the results page. My code is as follows:

if(!isset($search_string)) { $search_string = $_POST['search_string']; }
function callback($buffer) {

global $search_string;
// surround search item items with highlight class
return (ereg_replace($search_string, "<span class='highlight'>$search_string</span>", $buffer));

}

ob_start("callback");

// Code to display results and pagination goes here
...............................

ob_end_flush();

This works fine on the first page, results show ok with the search term highlighted. But when I click next page it takes an age to load and all I get where the results should be displayed is the actual source code. The results are there but so is all the code!

I am at a loss as what to do and how to fix it, any help well appreciated,

Thanks

tongpo

8:59 pm on Feb 5, 2005 (gmt 0)

10+ Year Member



Never mind it is sorted now. Nothing to do with output buffering, more to do with the fact that none of the pages but the first one were getting passed the search term :)
 

Featured Threads

Hot Threads This Week

Hot Threads This Month