new_to_php Posted June 25, 2007 Share Posted June 25, 2007 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 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.