我都是这样做的,但总是执行了!
$result = mysql_query("select * from b where name like '$value%' ")
这是查找是否有包含的内容!但不知如何判断,才能不包含的不执行啊!
$result = mysql_query("select * from b where name like '$value%' ")
这是查找是否有包含的内容!但不知如何判断,才能不包含的不执行啊!
解决方案 »
- PennyCMS网站内容管理系统
- 全角半角。。。
- 求固定时间加上分钟的问题 php
- php获取bing每日图片
- 哪位朋友给推荐一在linux下的html编辑器?
- 在Linux下的Apache启动时提示"Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName" ?
- PHP关于文件操作的问题,有知道的帮一下忙,谢谢了:)
- 如何调用类外的变量
- for 循环问题,太大的数组申请不了
- 大佬,Redis如何删除一个GEO地理位置数据???
- 浅谈PHP 的经验,大家畅所欲言!!!
- 一个关于数组的问题。
a表有一条记录1:30
b表有一条记录1:30,0:7,1:89 则为包含
如果b表的有一条记录为1:31,0:9,1:91 则不包含
while($row = mysql_fetch_array($result))
{
$smallimgtd_class="";
$smallimg_class="";
}
你这样当然会全部执行了,因为你的条件是全部包含1:30,
如果
包含就执行,不包含就跳过,这一过程
$result = mysql_query("select * from b where name")
while($row = mysql_fetch_array($result))
{
if(strpos($row['xxx'],"1:30")>0){
echo "包含";
}else{
} }
if($result && mysql_num_rows($result)>0){
do something;
}
如果逐条执行
$result = mysql_query("select * from b where name like '$value%' ")
while($row = mysql_fetch_array($result))
{
do something;//直接做就行了
}
a
name
1:30 b
name
1:30,0:7,1:89
1:32,0:8,1:90
1:31,0:9,1:91
1:30,0:40,1:60
1:30,0:5,1:90 select a.name from a, b where find_in_set(a.name, b.name);name
1:30
1:30
1:30
直接用T-SQL不就可以了吗?而且你说的包含,是指指定字段匹配还是所有字段匹配?
$data_a值就不多说了,
$data_b=array();
$result = mysql_query("select * from b")
while($row = mysql_fetch_array($result))
{
$temp_arr=explode(',',$row['对应字段']);
foreach($temp_arr as $value){
$data_b[]=$value;
}
}
然后只要这样判断
if(in_array($data_a,$data_b){
执行;
}esle{
不执行;
}