PHP将字符串插入现有url

时间:2017-06-25 08:51:39

标签: php

我是php新手,我目前正在使用排序/过滤搜索页面。但我无法弄清楚如何实现我想要的目标。

实施例: 现有网址:www.exaple.com/rentals?state=ca&city=el+monte

州:加州纽约州马里兰州弗吉尼亚州......

城市:El Monte ...

房间:一卧室两卧室三卧室......

价格:从高到低从低到高

如何将现有网址传递给链接? 例如,当我点击从高到低时,其网址应为: www.exaple.com/rentals?state=ca&city=el+monte&sort=pricel

这是我正在处理的PHP代码的一部分:

echo($_GET['state'] == "CA"))? "<i class=\"current\">CA</i>":"<i><a href=\"http://www.exaple.com/rentals?state=ca\">CA</a></i>";

echo($_GET['sort'] == "pricel"))? "<i class=\"current\">High to low</i>":"<i><a href=\"http://www.exaple.com/rentals?sort=pricel\">High to low</a></i>";

echo($_GET['bedroom'] == "1"))? "<i class=\"current\">1 Bedroom</i>":"<i><a href=\"http://www.exaple.com/rentals?bedroom=1\">1 Bedroom</a></i>";

当我点击马里兰州时,它会刷新页面并显示其城市。

马里兰州的超链接应该是: www.exaple.com/rentals?state=md

巴尔的摩(马里兰州城市之一)的超链接应该是 www.exaple.com/rentals?state=md&city=baltimore

但如果我点击价格:从高到低,它的超链接是: www.exaple.com/rentals?sort=pricel

和卧室的超链接是: www.exaple.com/rentals?bedroom=1

我的问题是如何将字符串传递给其他链接,以便它们成为: 适用于马里兰州和一卧室超链接 - www.exaple.com/rentals?state=md&bedroom=1

1 个答案:

答案 0 :(得分:0)

虽然你的问题有点模糊但是从我所理解的你想要将你的价值从正在使用的表格发布到另一个页面来实现这一点,

php的表单代码中的

指定ArrayList<String> fruits; ListAdapter myAdapter; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); fruits = new ArrayList<String>(); fruits.add("apple"); fruits.add("banana"); fruits.add("mango"); fruits.add("orange"); fruits.add("peach"); myAdapter = new CustomAdapter(this,fruits); .... } public void onClick (View view) { final EditText input = (EditText) findViewById(R.id.editText); String name = input.getText().toString(); fruits.add(name); myAdapter.notifyDataSetChanged(); } action='page to want data to go'

所以根据你提供的网址,它应该是:

method='GET'