2011-01-19 41 views
1
<form action="search.php" method="post" class="search" id="search"> 
    <input name="search" id="search" type="text" value=""><br> 
</form> 
... 
echo ".urlencode($_POST['search'])."; 

這裏是我的基本搜索框。我想要: 1.首先打開頁面,".urlencode($_POST['search'])."爲空。 2.當客戶鍵入某個單詞並進行搜索時,".urlencode($_POST['search'])."將始終在客戶類型字之後添加一個附加關鍵字。例如,當客戶端類型爲:apple時,".urlencode($_POST['search'])."部分顯示爲:apple20%juice,當客戶端類型爲:orange時,爲「.urlencode($ _ POST ['search'])」。部分顯示:orange20%juice,它總是在關鍵字後面添加附加關鍵字20%juice如何在搜索中添加其他關鍵字?

如何到達這個?謝謝。

+0

你的意思是'%20`,不`20 %`。這是空格字符的HTTP URL編碼表示。 – 2011-01-19 14:55:20

回答

0

這樣的:

檢查,如果搜索設置第一,如果這樣繼續前進,抓住繩子,添加果汁吧

if(isset($_POST['search'])) 
{ 
    $searchterm = $_POST['search']." juice"; 
    //follw by other stmts... 
} 
0

難道你不能簡單地使用;

print urlencode($_POST['search'].' juice');