• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php多条件外加查询

php 搞代码 3年前 (2022-01-24) 17次浏览 已收录 0个评论

php多条件叠加查询

<?<br />header("Content-Type:text/html;charset=utf-8");<br />include("../manage/include/function.php");<br />	$brand=substr($_POST["brand"],0,strlen($_POST["brand"])-1); <br />	$color=substr($_POST["color"],0,strlen($_POST["color"])-1); <br />	$caizhi=$_POST["caizhi"];<br />	$style=$_POST["style"];<br />	$kucun=$_POST["kucun"];<br />	echo($brand."</br>");<br />	echo($color."</br>");<br />	echo($caizhi."</br>");<br />	echo($style."</br>");<br />	echo($kucun);<br />	<br />	$q="select * from pros_pro where (1=1)";<br />	if($brand!=null){<br />		$q=$q+"and psp_brand in(".$brand.")";<br />	}<br />	if($color!=null){<br />		$q=$q+"and psp_col<strong style="color:transparent">本文来源gaodai#ma#com搞@@代~&码*网/</strong><strong>搞gaodaima代码</strong>or in(".$color.")";<br />	}<br />	if($caizhi!=null){<br />		$q=$q+"and psp_caizhi='".$caizhi."'";<br />	}<br />	if($style!=null){<br />		$q=$q+"and psp_style='".$style."'";<br />	}<br />	if($kucun!=null){<br />		$q=$q+"order by psp_stock desc";<br />	}else<br />	{<br />		$q=$q+"order by psp_id desc";<br />	}<br />	<br /><br />	$rows=query($q);<br />	if($row=mysql_fetch_array($rows))<br />	{<br />		do{<br />?><br />			<td align='right'><div align='center'><?php echo $row['psp_name'];?></div></td><br />	<?    }while($row=mysql_fetch_array($rows));<br />	}<br />	else<br />	{?><br />		<td align='right'><div align='center'>没有符合条件的信息,请重新定义搜索条件!</div></td><br />	<?<br />	}<br />	?>	

这个代码有神马问题?为什么会报错:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /data/home/hmu069081/htdocs/products/get_post.php on line 37
且没有符合条件的信息,可是我选的条件明明是有记录的

发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址