homepage Welcome to WebmasterWorld Guest from 54.198.94.76
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Search Results and Output buffering
tongpo




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

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




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

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 :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved