栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

mysql 引用php中变量查询

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

mysql 引用php中变量查询

没有变量的sql查询:

$sql=" select *  from ajaxtesttb where city='chengdu' and state='china' ";

有变量的sql查询:在字符串中用PHP变量的方法是变量外面用大括号

$sql=" select *  from ajaxtesttb where city='{$city}' and state='{$state}' ";


$host="192.168.21.103";
$sql="select a.host_object_id,a.display_name host_name,a.address,c.display_name,b.state,b.start_time,b.end_time,b.output from nagios_hosts a,nagios_servicechecks b,nagios_services c where a.host_object_id=c.host_object_id and b.service_object_id=c.service_object_id and ( c.display_name='Current Load' or c.display_name='check-load') and a.address='{$host}' order by b.servicecheck_id desc limit 0,38";


整个sql语句要用""双引号括起来,然后php变量用单引号加大括号的形式:'{$host}'

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/227987.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号