PHP 依据选择改变网址的参数

WBOY
Release: 2016-06-13 12:04:18
Original
1107 people have browsed it

PHP 根据选择改变网址的参数
例如
                    家教
                    模特
                    派单
                    文员

                    石排
                    企石
                    横沥
                    桥头
                    谢岗
                    东坑
                    常平
而网址有两个参数:http://www.aaa.com?type=0&town=企石

当我选了桥头,网址就变成http://www.aaa.com?type=0&town=桥头
当我先了桥头+文员,网址就变成http://www.aaa.com?type=3&town=桥头

这用PHP如何实现呢?
------解决方案--------------------
建議參數全部用數字,如果沒有參數,可以默認不出或者只出第一個

<br />$types = array('<a href="" style="color:;">家教</a>','<a href="" style="color:;">模特</a>','<a href="" style="color:;">派单</a>','<a href="" style="color:;">文员</a>');<br />$towns = array('<a href="" style="color:;">石排</a>','<a href="" style="color:;">企石</a>','<a href="" style="color:;">横沥</a>','<a href="" style="color:;">桥头</a>','<a href="" style="color:;">谢岗</a>','a href="" style="color:;">东坑</a>','<a href="" style="color:;">常平</a>');<br /><br />$type = isset($_GET['type'])? intval($_GET['type']) : 0;<br />$town = isset($_GET['town'])? intval($_GET['town']) : 0;<br /><br />if(isset($types[$type])){<br />	echo $types[$type];<br />}<br /><br />if(isset($towns[$town])){<br />	echo $towns[$town];<br />}<br />
Copy after login


http://www.aaa.com?type=1&town=2
輸出
模特
横沥

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!