duanbu9345 2012-02-27 14:42
浏览 13
已采纳

在会话中保持搜索表单过滤器

I have different search form on different pages for example at page i have a searchform on lefthand side. http://www.terra-reisen.com/

Similarly on preview page a form in header area http://www.terra-reisen.com/web/index.cfm/pm/uebersicht#1

and on detail page clicking on "Termine & preise" tab one can see another form. http://www.terra-reisen.com/web/index.cfm/pm/detail/idobjekt/4799/suchartFrom/uebersicht

Now what I want to develop is a kinf of Filter Container for each page. I mean If user filters some data on start page for example country=Austrie(in searchform) and come on preview page and filter again for a specific city and the comes to detail page now I have from detailpage come to preview page, the selected filters should be applied automatically and similarly from preview to startpage all the fileters should be applied.

Is there any design pattern or something like avialble for such sitution?

  • 写回答

1条回答 默认 最新

  • dougaoshang0237 2012-02-27 14:53
    关注

    You should write a php script that creates a session with the filters, this script will also need to check if that session exists and if so to grab the filters from it and apply them.

    You can write that script once and then just include it in all the pages. An example:

    session_start();
    
    $filters = array('location' , 'age' , 'language')
    
    if (!isset($_SESSION['filters'])) {
      if(array_key_exists('set_new_filters', $_POST)) //the name of the submit button of the filters form
      {
         foreach($filters as $filter)
         {
             $session_filters = $filter.":".$_POST[$filter].";";
         }
         $_SESSION['filters'] = $session_filters;
      }
    } else {
    
      $user_filters = explode(";" , $_SESSION['filters']);  
      /*
      $user_filters: Array (
         [0] => location:somevalue
         [1] => age:somevalue
         [2] => language:somevalue
      )
      */
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度