Jump to content

new_to_php

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

new_to_php's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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; } } } }
  2. But I am using PHP 4.3.2 , than hpw to resolve the problem ?
  3. Hi , First I started with sessions only.But I have problems with sessions. In a browser if i open 2 tabs , they share same session. If i make changes in tab2 then tab1 will also be affected because they sahre same session. So instead of session i want to go for url rewriting. Is there any way other than sessions ?
  4. Hi , I mean to say : I have a array in Test.php as $test_array = array(); Contents of that array are set at when you click any button on that page (at run time). echo(" <a href=\"$PHP_SELF?page=$i\">CLICK ME</a>"); In Test.php I have link called "CLICK ME" , again it will refer to that same php file , at that point of time I want to use the array "test_array". I am using the URL rewriting. how can i get the array in the new page ? Thank you
  5. Hi , I am using url rewriting in my php script. How can I set the variables so that I can access them in another PHP pages which are referenced by this page ? means .. If we use sessions we can use session variables so that we can access them in another another pages. how it can be done in url rewriting ?? if(version_compare(phpversion(),'4.3.0')>=0) { if(!ereg('^SESS[0-9]+$',$_REQUEST['SESSION_NAME'])) { $_REQUEST['SESSION_NAME']='SESS'.uniqid(''); } output_add_rewrite_var('SESSION_NAME',$_REQUEST['SESSION_NAME']); session_name($_REQUEST['SESSION_NAME']); }
  6. Hi , I am implementing seach functionality in a website. Taking the keyword , search all the pages and storing results in result_array. Results are displayed PAGE WISE. (like PREV 1 2 3 NEXT) If user clicks on "2" I am displaying from result_array[10] to result_array[19] like that. So I took result_array as session variable. session_start(); session_register("result_array"); It is working fine , If I took 2 different browsers and test tha functionality on different browsers. BUT problem is : 1. I open a browser (TAB1), open that website , give a keyword to search. Suppos it showed 30 results in 3 pages ( Prev 1 2 3 Next ) Than , Open new TAB (TAB2) on same browser , open that website , give different keyword for search. suppose it shows 50 results in 5 pages ( Prev 1 2 3 4 5 Next) NOW go to TAB1 .. Here problem comes , when I click on any page (suppose "2") result is over written by TAB2 results. I think it is becaues result_array is taken as session variable , how to solve it ? How to over come this problem. Thank you.
  7. Hi , I am implementing search functionality in a website. ( internal search). In that I am taking a keyword as input and searching all the pages and storing results in an array. I want to display 10 results per page. I wrote below logic for that. result_array: stores all results. session_start(); session_register("result_array"); //Some code to search for keyword and store results in result array. function display_result(){ global $result_array,$page; $file_count=1; $result_count=count($result_array); $page_count=$result_count/10 + 1; echo "Total $result_count results found in $page_count pages <br>"; $start=$page*10-9; if($result_count<$page*10){ $end=$result_count; } else { $end=$page*10; } for($x=$start;$x<=$end;$x++){ $title = $result_array[$x][0]; $url = $result_array[$x][1]; $des = $result_array[$x][2]; echo "$file_count.<a href=$url >$title</a>"; echo "<br>"; echo "$des<br>"; $file_count++; } echo " \t\t <br> Result Page: "; for($i=1;$i<$page_count;$i++) { echo " <a href=\"$PHP_SELF?page=$i\">$i</a> "; } 1. Here when I click the Page 2 or 3 in result , all result contents are coming correctly. But format is not proper,as it is in first page.Font is also changes in other pages. why alignment of result is changed like that. 2. When I click any page (2 or 3) total PHP page is getting executed again , I want only the display_result() to be executed , how it can be done ? Thank you
  8. Hi , stripos is not supported in PHP4. How can I do case INsensitive strpos in PHP4 ? $Position = strpos($data,$searchWord); above is case sensitive Is there any work around in PHP4 ?
  9. Hi , I have written following code to search in my internal website. I am going through every directory and files in that directory , to search for a particular keyword(search string).If I found that keyword I store that file name in an array. $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file")); if(eregi("$keyword",$data)) { $array[]="$dir/$file"; $startPosition = strpos($data,$keyword); $startPosition -= 40; if ($startPosition < 0) { $startPosition = 0; } $context = substr($data,$startPosition,80); echo "context: $context"; print '<pre>'; My intention is to store some text around the keyword inorder to display it in result (40 chars before and 40 chars after keyword). My problem is : If a file is like this : <html> <head> <title>Sample File</title> </head> <body> This is a sample HTML file to test PHP search functionality </body> </html> 1. If I search for keyword "sample" in output(echo "$context") it is showing HTML tags also. means <body> This is a sample HTML file to test PHP search functionality </body> like that. In output result I dont want those tags. How to remove those tags. 2. If I find search string in a file , I want to capture that file title. How it can be done ??? ( In above case <title>Sample File</title> , I want co capture "sample File" ) Thank you ..
  10. Hi , My Problem is : In my FIRST HTML page I have 2 frames (vertical). In frame 1 mypage.html is displayed. ( <FRAME SRC="mypage.html" NAME="frame1"> ) in mypage.html , I have a SUBMIT button. When I click that It will call a PHP script .In that some calculations will be done and results are stored in one array. My requirement is display that array contents in my FIRST HTML page's SECOND frame. please suggest me a solution.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.