php - How to store post variables value -


i got index page on search page included, , when submit it, passes values find.php through action , method post. code below

if($_post['searchsubmit']=="search"){ $cat=$_post['searchcategory']; $area=$_post['searcharea']; $term=$_post['searchbox']; } 

the above code written on find.php, when try implement paging through basic paging method conditions make appropiate search query

$where="where approved='yes'";         if($term!=""){             $where.=" , name '%$term%'";         }         if($cat!=""){             $where.=" , category '%$cat%'";         }         if($area!=""){             $where.=" , area '%$area%'";         }         $start=0;         $end=5;         if($_get['page']!="")         {             $start=$_get['page']*$end;         } 

where $start initial limit, , $end number of records. first page of paging, pass variable page 0 first page

<a href="find.php?page=<?php echo 0;?>">first</a> 

and search query becomes

$que="select * shops ".$where." order likes desc  limit $start,$end"; 

as click on "first", new link become "/find.php?page=0" , post values recivied index page search bar lost.

is there way retain values ?the 2 methods though sending them again through url get, or other way store them in session. there third method available ?

marc absolutely right. not use code is.

as alternate solution problem -

  • your page index.php (search form) submits itself
  • assemble search query querystring in index.php if post
  • redirect find.php assembled querystring
  • every search information in querystring.
  • use pagination happily.

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -