phpcms 多城市站点中遇到的问题,pc标签where中如何使用变量

问题以及解决方案

{pc:content action="lists" catid="$catid" where="typeid='$t'" order="id DESC" num="30"}
如上代码,模板解析时,总是把where="typeid='$t'"中typeid='$t' 解析成字符串,不会解析$t变量

解决方法:

{php $where = "typeid=$t"}
{pc:content action="lists" catid="$catid" where="$where" order="id DESC" num="30"}
用字符串的方式传递where条件

where如何实现多条件查询,以及如何判断字段中是否包含某个字符串

方法1 like

SELECT * FROM 表名 WHERE 字段名 like "%字符%";

方法2 field_in_set

SELECT * FROM users WHERE find_in_set('字符', 字段名);

在PHPcms实现城市信息的查询,实现如下

{php $chengshi=$_GET['chengshi']}
{php $where1 = "zhiding=1 and find_in_set('$chengshi', chengshi)"}
{pc:content action="lists" catid="265"  where="$where1"   siteid="1"  num="1"  order="inputtime desc"}
{loop $data $v}
XXXXX
{/loop}
{/pc}
原文地址:https://www.cnblogs.com/cn-oldboy/p/12872058.html