PHP實現搜尋時記住狀態的方法樣本

來源:互聯網
上載者:User
這篇文章主要介紹了PHP實現搜尋時記住狀態的方法,結合執行個體形式分析了php通過get參數傳遞及DOM元素形式記錄搜尋狀態的相關操作技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文執行個體講述了PHP實現搜尋時記住狀態的方法。分享給大家供大家參考,具體如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>PHP Of Search Remember state</title></head><!--方式一 模版擷取GET參數方式記住條件--><php>$start = $_GET['start'];$end = $_GET['end'];</php><!--方式二 DOM載入方式傳遞條件--><php>$search = $_GET['search'];</php><script type='text/javascript'>//DOM載入結束$(function(){{if:$this->search}var searchData = {echo:JSON::encode($this->search)};for(var index in searchData){$('[name="search['+index+']"]').val(searchData[index]);}{/if}});</script><body><!--方式一 模版擷取GET參數方式記住條件-->時間:<input type="text" name='start' value='{$start}' /> —— <input type="text" value="{$end}" name='end' /><!--方式二 DOM載入方式傳遞條件-->姓名:<input name="search[username]" type="text" value="" />電話:<input name="search[telphone]" type="text" value="" /></body></html>

補充:

此外還需要注意,普通的GET請求形如:http://yourWebname.com/index.php?ids=1&ids=2 可傳遞對應的單個參數

而使用形如:http://test.tmp/index.php?ids[]=1&ids[]=2 的形式可傳遞數組參數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.