多条查询 大家进来看看! 就是构造动态SQL语句。PHP俺不熟悉。也最好用存储过程来写。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你这写的到底是asp还是php啊?这是改过的php程序:<?php//$query="select * from test where 1=1 order by id desc";$sql="select * from test where 1=1";if($id!="") $sql = $sql . " and id=" . $id;if($ycity!="不限") $sql = $sql . " and ycity='" . $ycity . "'";if($ystyle!="不限") $sql = $sql . " and ystyle='" . $ystyle . "'";if($ymoney!="不限") $sql = $sql . " and ymoney between " . replace(ymoney,"-"," and ");//以上这句没看懂你的意思,自己参考$yarea改改if($yarea<>"不限" )//and isnumeric($yarea)(不要放在这里判断) { $tmp=$yarea; if ($tmp>=6) $sql = $sql . " and yarea>=200 "; else $sql = $sql . " and yarea > " . ($tmp-1)*40 . " and yarea <" . $tmp*40; }$sql = $sql . " order by id desc";?> 是多条件查询语句。实质上就是构建一个动态SQL语句,在PHP中要特别注意数值型字段的引用,如果构造的SQL中字段值没加引号,建议引用时选取intval值! php 我的查询不会 所以我把我做的asp 查询 向转成 php 的! 所以大家帮我看一看! 错误提示!Call to undefined function: replace()$sql = $sql . " and ymoney between " . replace(ymoney,"-"," and "); $sql = $sql . " and ymoney between " . replace(ymoney,"-"," and ");replace是asp函数啊我不知道你这句话什么意思,ymoney between 后面怎么只有一个值? 看明白了,再试试<?php//$query="select * from test where 1=1 order by id desc";//$ymoney="ywe-hnrhth";$sql="select * from test where 1=1";$arr_money = explode("-", $ymoney);if($id!="") $sql = $sql . " and id=" . $id;if($ycity!="不限") $sql = $sql . " and ycity='" . $ycity . "'";if($ystyle!="不限") $sql = $sql . " and ystyle='" . $ystyle . "'";if($ymoney!="不限") if(sizeof($arr_money)==2) $sql = $sql . " and ymoney > $arr_money[0] and ymoney < $arr_money[1]";if($yarea<>"不限" )//and isnumeric($yarea)(不要放在这里判断) { $tmp=$yarea; if ($tmp>=6) $sql = $sql . " and yarea>=200 "; else $sql = $sql . " and yarea > " . ($tmp-1)*40 . " and yarea <" . $tmp*40; }$sql = $sql . " order by id desc";echo $sql;?> 发个违规贴 php下fckeditor问题! PHPWind出售贴如何统一换成交易币 ■■■■要使用file_get_contents函数需要开启防火墙那个端口? Parse error: syntax error, unexpected T_VARIABLE 各位帮我看看有什么问题 thinkphp如何实现以下需求 招募在京奋战的php战士 PHP的SOCKET 【PHP】 IIS下用$_POST[""]获取表单数据导致HTTP500内部错误 symfony除了用FOSUserBundle还有什么方法实现入口方法 这样写不对吗?请指教。 一个简单的问题,怎么判断数据库中是否有某条数据
这是改过的php程序:
<?php
//$query="select * from test where 1=1 order by id desc";
$sql="select * from test where 1=1";
if($id!="")
$sql = $sql . " and id=" . $id;
if($ycity!="不限")
$sql = $sql . " and ycity='" . $ycity . "'";
if($ystyle!="不限")
$sql = $sql . " and ystyle='" . $ystyle . "'";
if($ymoney!="不限")
$sql = $sql . " and ymoney between " . replace(ymoney,"-"," and ");
//以上这句没看懂你的意思,自己参考$yarea改改
if($yarea<>"不限" )//and isnumeric($yarea)(不要放在这里判断)
{
$tmp=$yarea;
if ($tmp>=6)
$sql = $sql . " and yarea>=200 ";
else
$sql = $sql . " and yarea > " . ($tmp-1)*40 . " and yarea <" . $tmp*40;
}
$sql = $sql . " order by id desc";
?>
Call to undefined function: replace()$sql = $sql . " and ymoney between " . replace(ymoney,"-"," and ");
replace是asp函数啊
我不知道你这句话什么意思,ymoney between 后面怎么只有一个值?
<?php
//$query="select * from test where 1=1 order by id desc";
//$ymoney="ywe-hnrhth";
$sql="select * from test where 1=1";
$arr_money = explode("-", $ymoney);
if($id!="")
$sql = $sql . " and id=" . $id;
if($ycity!="不限")
$sql = $sql . " and ycity='" . $ycity . "'";
if($ystyle!="不限")
$sql = $sql . " and ystyle='" . $ystyle . "'";
if($ymoney!="不限")
if(sizeof($arr_money)==2)
$sql = $sql . " and ymoney > $arr_money[0] and ymoney < $arr_money[1]";
if($yarea<>"不限" )//and isnumeric($yarea)(不要放在这里判断)
{
$tmp=$yarea;
if ($tmp>=6)
$sql = $sql . " and yarea>=200 ";
else
$sql = $sql . " and yarea > " . ($tmp-1)*40 . " and yarea <" . $tmp*40;
}
$sql = $sql . " order by id desc";
echo $sql;
?>