new_to_php Posted July 18, 2007 Share Posted July 18, 2007 Hi , I am implementing search functionality for a small set of files. In below code: $keyword_array refers to a search string. I am searching for a word in a file and printing on screen.All results are displayed in a single page. Here I want to use paging , splitting results in different pages. how it can be done ? one solution could be: I will store all results in an array , make array as session variable and use paging. problem with above is: 1. In below code , I am displaying results as soon as I found in any file. But with above approch I have to wait till all results are stored in an array. 2. Paging with browser TABS is failing. Because two tabs in a browser uses same session. So the session variable in one TAB will be overwritten by the sassion variable in another TAB. How to over come above problems ? function CheckFiles($dir) { $handle=opendir($dir); while(false!==($file=readdir($handle))) { if(is_dir("$dir/$file")) { CheckFiles("$dir/$file"); } else { $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file")); $data=strip_tags($data); foreach($keyword_array as $value1) { if(eregi($value1,$data)) { $url ="$dir/$file"; echo("<a href=$url > $url</a>"); echo("<br>"); break; } } } } Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted July 18, 2007 Share Posted July 18, 2007 you really need to read the pagination tutorial on PHP freaks... it's excellent and does exactly what you want. go to http://www.phpfreaks.com/tutorial_cat/25/Page-Number--Pagination.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.