我的SQL语句是这样写的:Select ID,ParentsID,ProName,ProSImg,SImgAlt,HtmlUrl From ProductsInfo where IsShow=True and instr(','ParentsID_r',',',".$_REQUEST["list"].",')>0 Order By ToSort desc
整个代码是这样的<?php
$str="Select ID,ParentsID,ProName,ProSImg,SImgAlt,HtmlUrl From ProductsInfo where IsShow=True and instr(','ParentsID_r',',',".$_REQUEST["list"].",')>0 Order By ToSort desc";
$result=mysql_query($str,$link);
$num=mysql_num_rows($result);
for($i=0;$i<$num;$i++)
{
$row=msql_fetch_array($result);
echo $row["ProName"];
}
?>
可是为什么上面传过来的sql语句却查不到值呢,页面上什么也不显示为空白,调试也不报错。请大家帮我看看是哪里出错了。
整个代码是这样的<?php
$str="Select ID,ParentsID,ProName,ProSImg,SImgAlt,HtmlUrl From ProductsInfo where IsShow=True and instr(','ParentsID_r',',',".$_REQUEST["list"].",')>0 Order By ToSort desc";
$result=mysql_query($str,$link);
$num=mysql_num_rows($result);
for($i=0;$i<$num;$i++)
{
$row=msql_fetch_array($result);
echo $row["ProName"];
}
?>
可是为什么上面传过来的sql语句却查不到值呢,页面上什么也不显示为空白,调试也不报错。请大家帮我看看是哪里出错了。
你这样写对吗?instr 只有两个参数,返回第一个参数在第二个中第一次出现的位置
你的意思是不是后面一个参数是 ,"21",如果是这样的话 是你拼接字符串的问题吧
应该是instr(',ParentsID_r,',',\"'.$_REQUEST["list"].'\",') 而且mysql中的双引号貌似也要转义
你这个东西太麻烦了 我没测试 你多测试测试就好了 关键你这里的符号太多了
看看输出啥
SQL语句中应该这样写才对吧?
instr(','+ParentsID_r+',',',".$_REQUEST["list"].",')>0