- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我一直在尝试根据选定的城市名称在数据库中创建公司或子类别的自动完整搜索,但它似乎对我不起作用。谁能帮我?下面是我的代码:
include( "dbconnect.php" );
$q = strtolower( $_GET['q'] );
$city = intval( $_GET['city_val'] );
if ( $city != "-1" )
{
if ( !$q )
{
}
else
{
$query = "SELECT DISTINCT concat(listing.company_name,' (',locality.locality,')') as name,listing.id as id,listing.type as type FROM listing,locality where listing.locality=locality.id AND listing.city='{$city}' AND LCASE(company_name) like '%".{$q}."%' UNION select DISTINCT sub_cat_name as name,subcategory.id as id,subcategory.type as type FROM subcategory where LCASE(sub_cat_name) like '%".{$q}."%' order by name";
}
}
else
{
if ( !$q )
{
}
else
$query = "SELECT DISTINCT concat(listing.company_name,'<br>(',locality.locality,' ',city.city,' ',state.statename,')') as name,listing.id as id,listing.type as type FROM listing,locality,city,state where listing.locality=locality.id AND listing.city=city.id AND listing.state=state.id AND LCASE(company_name) LIKE '%".{$q}."%' UNION select DISTINCT sub_cat_name as name,subcategory.id as id,subcategory.type as type FROM subcategory where LCASE(sub_cat_name) LIKE '%".{$q}."%' order by name";
}
}
$results = mysql_query( $query );
while ( $result = mysql_fetch_array( $results ) )
{
$array[] = array('name'=>$result['name'], 'id'=>$result['id'], 'type'=> $result['type']) ;
}
echo json_encode($array);
您还可以在下面查看我的 jquery 代码:
<script>
$(function() {
$( "#companies" ).autocomplete({
source: 'companies.php'
});
});
</script>
最佳答案
自动完成方法将“term”作为默认键传递。所以如果你想得到结果你必须这样做:
$q = strtolower($_GET['term'] );
如果你想自定义它然后使用ajax。
看这个:
Can the default "Term" name passed in the "jquery UI autocomplete" feature be changed?
关于php - 基于城市和地区的自动完成搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41917333/
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
在我的 MVC 应用程序中,我想显示用户访问网站的国家/地区、地区和城市。我怎样才能获取它们? 最佳答案 有几种方法。一种是要求用户与远程服务器共享他的位置。 https://developer.mo
有人知道Firebase电话身份验证是否适用于印度电话号码吗? 我成功实现并使用了美国号码(+1xxxxxxxxxx),但是尝试使用印度电话号码时未收到文本。不确定是否无法正常工作,或者我丢失了某些东
我想知道网站的原始国家/地区。我注意到Alexa网站通常可以检测网站的原始国家/地区。例如,Alexa可以检测到stackoverflow.com网站的原始国家/地区是美国,依此类推。 Alexa如何
我有一些文本,其中可能包含也可能不包含国家/地区名称。例如: ' Nigeria: Hotspot Network LTD Rural Telephony Feasibility Study' 这就是
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭10 年前。 Improve th
我有一组值,它们是我的 ajax 调用中的国家/地区代码 Handler.getCountryIdparam1, {callback:function(data){ // data will
我在我的应用程序中使用谷歌地点。一切正常,但我只想从输入中删除或忽略国家/地区。 例如,如果输入“arc”我有 Arcachon, France Arcueil, France Archamps, F
在 firebase 中创建项目时,我错误地选择了错误的国家/地区。 正如您在这里看到的: 这个问题可以解决吗? (我知道项目 ID 无法更改,而且我喜欢我选择的 ID...) 最佳答案 如the d
我有一个名为“Login”的Hive表。它包含以下列: UserID | UserName | UserIP | UserCountry | Date 在特定的一天(当天的所有登录信息),我想找出用户
我正在使用谷歌地图和地理编码API来检索用户输入邮政编码/邮政编码后的纬度/经度,但我想将邮政编码/邮政编码限制为该用户所在的国家/地区,这样我就不会得到结果多个结果。 是否有一种方法可以使用 jqu
是否可以获得维基百科上所有有关系的国家、地区和城市的列表?我找不到任何适合此任务的 API。解析我需要的所有信息的最简单方法是什么?PS:我知道,我可以从其他数据源获取此信息。但我对维基百科感兴趣..
我正在用两种语言制作一个网站。是否可以检查用户位于哪个国家,以便我可以自动为用户切换语言?我的菜单中还有一个带有 _GET 的切换选项。我一开始有这段代码: if (isset($_GET['taal
这是我的 Firebase 数据库结构: 看起来就是这样。有国家和用户。如果用户访问过某个国家/地区,则该国家/地区将存储在该用户的“VisitedCountries”子项中。例如用户 Angelin
这个问题在这里已经有了答案: Convert latitude and longitude coordinates to country name in R (2 个回答) 关闭9年前. 我有一个带有
我目前正在开发我的第一个iOS应用(phonegap / cordova)。我想知道是否需要采取某些步骤,以使其不仅可用于德国应用程序商店(这是我的语言),还可以提供给国际应用程序? 最佳答案 不,你
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
背景 我目前正在开发一个向用户提问的 Android 应用程序。目前我正在创建用于提问的模块。现在我正在开发一个地形模块,它将能够向用户询问有关某个国家/地区的各种问题,并向他们显示。 问题 对于本模
我正在使用 Cloudera 的 TwitterSource for Flume。我想按国家/地区获取具有某些关键字的推文。当我想获取来自荷兰的推文时,我不知道该与什么进行比较。我有以下结果,但没有任
大多数 Web 应用程序都有一个位置字段,用户可以在其中输入自己选择的位置。 如何根据输入的位置将用户分类到不同的国家/地区。 例如,我使用了 users.xml 的 Stack Overflow 转
我是一名优秀的程序员,十分优秀!