index.php?chid=4&ccid18=197
这是个网址,如何让点击下一个连接的时候这个网址在浏览器地址栏里的地址变成
index.php?chid=4&ccid18=197&ccid17=166
也就是说增加了个
&ccid17=166
在点击下下一个网址就叠加成了
index.php?chid=4&ccid18=197&ccid17=166&ccid18=196
在一次增加了个
&ccid18=196
这个地址呢?
求不使用搜索框的方法方式。
这里高手很多,上次在这里解决了个重要的问题,今天又来了,非常感谢!搜索浏览器
这是个网址,如何让点击下一个连接的时候这个网址在浏览器地址栏里的地址变成
index.php?chid=4&ccid18=197&ccid17=166
也就是说增加了个
&ccid17=166
在点击下下一个网址就叠加成了
index.php?chid=4&ccid18=197&ccid17=166&ccid18=196
在一次增加了个
&ccid18=196
这个地址呢?
求不使用搜索框的方法方式。
这里高手很多,上次在这里解决了个重要的问题,今天又来了,非常感谢!搜索浏览器
&ccid18=196
这种连接是查询的字段
所以每叠加一个就多一个查询的条件,查询出来的东西就更细致了
客户端用js把各个input type组合起来再发送就是(不一定需要submit)另一种做法更简单,php直接写一个js变量,值就是当前网址,js再处理——改变就替换,增加就拼接,然后location
跳转的url = window.location.href + (window.location.href.indexOf('?') ? '&':'?')+ ccid的name + '=' + ccid的值)
这个是当前网址
然后你在这个基础上附加 你的变量就好
现在是这样的,我要的是这样的
<?php $base_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?';parse_str($_SERVER['QUERY_STRING'], $query_strings);foreach(array('ccid1', 'ccid2', 'ccid3', 'ccid4') as $ccid) {
$strings = $query_strings;
unset($strings[$ccid]);
$strings[$ccid] = '';
${$ccid.'_url'} = $base_url.http_build_query($strings);
} ?><a href="<?php echo $ccid1_url; ?>1" target="_self">ccid1</a>
<a href="<?php echo $ccid2_url; ?>2" target="_self">ccid2</a>
<a href="<?php echo $ccid3_url; ?>3" target="_self">ccid3</a>
<a href="<?php echo $ccid4_url; ?>4" target="_self">ccid4</a>
只需在 search.php 的开始处加入以下代码
if(! $_GET) { //首次进入清楚 cookie
foreach($_COOKIE as $k=>$v) setcookie($k, '');
}else {
//将传入的参数保存于 cookie 中
foreach($_GET as $k=>$v) setcookie($k, $v);
//取回上次保存的参数
$_GET = array_merge($_COOKIE, $_GET);
//$_GET 中就含有了诸复合查询条件了
}
测试例<?php
if(! $_GET) {
foreach($_COOKIE as $k=>$v) setcookie($k, '');
}else {
foreach($_GET as $k=>$v) setcookie($k, $v);
$_GET = array_merge($_COOKIE, $_GET);
print_r($_GET);
}?>
<p> </p>
<label><a href="?chid=4&ccid17=164" >5000元以下</a></label>
<label><a href="?chid=4&ccid17=166" >5000-7000元</a></label>
<label><a href="?chid=4&ccid17=167" >7000-10000元</a></label>
<label><a href="?chid=4&ccid17=168" >10000-15000元</a></label>
<label><a href="?chid=4&ccid17=169" >15000元以上</a></label>
<p> </p>
<label><a href="?chid=4&ccid12=3" >普通住宅</a></label>
<label><a href="?chid=4&ccid12=2" >公寓</a></label>
<label><a href="?chid=4&ccid12=3032" >商住</a></label>
<label><a href="?chid=4&ccid12=3023" >写字楼</a></label>
<label><a href="?chid=4&ccid12=3024" >商铺</a></label>
<label><a href="?chid=4&ccid12=4" >别墅</a></label>
<label><a href="?chid=4&ccid12=1" >四合院</a></label>
<label><a href="?chid=4&ccid12=3058" >仓库</a></label>
<label><a href="?chid=4&ccid12=5" >其他</a></label>