1
http://example.com/bills.php?sort=highest
http://example.com/bills.php?sort=alpha
http://example.com/bills.php?sort=lowest
所以網址aboves排序最高,字母和最低。他們使用$ _GET方法並使用表單。我想知道是否有一種方法來提交表單/獲取$ _GET數據而不更改網址?
<form action="bills.php" method="get">
<select onchange="this.form.submit();" name="sort" class="right sort">
<option>What would you like to sort by?</option>
<option value="highest" <?php if(isset($_GET['sort']) && $_GET['sort'] == 'highest'){?> selected="selected" <?php } ?>>Highest to Lowest</option>
<option value="lowest" <?php if(isset($_GET['sort'])&& $_GET['sort'] == 'lowest'){?> selected="selected" <?php } ?>>Lowest to Highest</option>
<option value="alpha" <?php if(isset($_GET['sort'])&& $_GET['sort'] == 'alpha'){?> selected="selected" <?php } ?>>Alphabetically</option>
</select>
</form>
上面是我可以提交新的排序請求的代碼。
我想提出我的網址留在example.com/bills.php
那會是可能的嗎?
這將是可能改寫使用.htaccess中的網址是什麼?我已經嘗試了URL重寫方法,它允許我去參觀http://example.com/bills/alpha
,它工作正常,但是當我選擇一個新的查詢,它變成http://example.com/bills/bills/?sort=alpha
。
這裏是我的.htaccess
RewriteEngine On
RewriteBase/
RewriteRule ^bills/(.*)$ /bills.php?id=$1
請使用帖子代替嗎? – HamZa
使用形式方法後,保持值在一個隱藏字段相同的形式 – ejo
下不使用後*是否有你的任何理由*? – Novocaine