Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php搜索脚本_Php - Fatal编程技术网

php搜索脚本

php搜索脚本,php,Php,我需要一些帮助来搜索像在上搜索的属性 我不知道的是,如何将查询发送到下一页?我的问题是这样的 $query = select * from xyz where city='a' and location='b' and price between 'c' and 'd' and area between 'e' and 'f' and bedrooms='g' and addedwithin 'h'; <a href="<?php echo $_SERVER['PHP_SELF'

我需要一些帮助来搜索像在上搜索的属性

我不知道的是,如何将查询发送到下一页?我的问题是这样的

$query = select * from xyz where city='a' and location='b' and price between 'c' and 'd' and area between 'e' and 'f' and bedrooms='g' and addedwithin 'h';
<a href="<?php echo $_SERVER['PHP_SELF'] . '?q=' . $query; ?>" > nextpage </a>
考虑到基于上述网站上表格的查询,搜索房地产清单的场景应该是什么

另外,当我对该页面使用分页时,应该如何再次获取该查询。应该是这样吗

$query = select * from xyz where city='a' and location='b' and price between 'c' and 'd' and area between 'e' and 'f' and bedrooms='g' and addedwithin 'h';
<a href="<?php echo $_SERVER['PHP_SELF'] . '?q=' . $query; ?>" > nextpage </a>

或者还有其他更简单的解决方案吗


谢谢

你可以做几件事。一种解决方案是将查询字符串中需要的所有参数与页码一起传递,然后执行。这可能适用于较小的内容,但如果在搜索后将某些内容插入到表中,则可能会出现问题,因此搜索结果可能会增加/减少,并且对用户来说似乎很奇怪。如果爬行器开始通过增加页面参数来爬行您的站点,那么也会有一个问题——这很容易使您的数据库过载


我最喜欢的另一个解决方案是,使用某个唯一的ID作为密钥,将初始搜索的所有结果保存到一个数据库中。然后,可以向您的分页传递缓存项ID和页码,您可以从结果数组中读取所需的页面。

您可以存储用户搜索短语,例如会话中的coockies或保留表单中的参数(例如隐藏类型)。然后使用新的偏移量再次执行db请求