热搜:NVER node 开发 php

怎么才能列出字段所有的值呢

2024-07-25 16:20:01
怎么才能列出字段所有的值呢

haop字段:好评等于1,中评等于2,差评等于3
select * from pingjia where uid='$uid' and  haop='$haop' order by id desc limit";

现在是
?uid=5&haop=1 可以列出等于1的好评,现在想显示全部的怎么搞啊

$radio=intval($_GET['haop']);
if($radio===0){
$pingx="比如提交value=’0‘的时候怎么显示全部呢";
}
else
{
$pings="&haop=$radio";
}


回复讨论(解决方案)

你把sql改成select * from pingjia where uid='$uid' order by id desc;就好啦

把 and  haop='$haop' 去掉就可以了。

可是去掉and  haop='$haop'就不能查询到这个值了

例如这样的,去掉就不生效了...
?uid=5&haop=1 

用了个笨办法
if($radio===0){
select * from pingjia where uid='$uid' and  haop='$haop' order by id desc limit";
}
else
{
select * from pingjia where uid='$uid' order by id desc limit";
}

虽然能行了,但好像太不科学了,哎!~

一般这种条件查询语句是这样写的

$sql  =  "select xx  from  yy where 1=1"; if(条件1){$sql .= "  and  a=.. ";} if(条件2){$sql .= "  and b=.. ";}然后后面跟上分页和order

你去掉了and  haop='$haop',后边url地址后边就不要跟&haop=1了。