首页上一页 1 下一页尾页 1 条记录 1/1页
《PHP程序设计》--第十四章,findsp.php
发表在PHP图书答疑
2016-08-25
是否精华
是
否
版块置顶:
是
否
老师你好,
我不大明白这里$mh和$dx的意义?从top.php页面传递过来jdcz和name,就可以完成查询匹配了,为什么还要这两个变量呢?另外,之前没有$mh和$dx,这里是否是在声明变量?
$mh=isset($_POST['mh'])?$_POST['mh']:"";
$dx=isset($_POST['dx'])?$_POST['dx']:"";
另外,$jg和$lb,也是同样的问题?
$jg=intval(isset($_POST['jg'])?$_POST['jg']:"");
$lb=isset($_POST['lb'])?$_POST['lb']:"";
<?php
$jdcz=$_POST['jdcz'];
$name=$_POST['name'];
$mh=isset($_POST['mh'])?$_POST['mh']:"";
$dx=isset($_POST['dx'])?$_POST['dx']:"";
if($dx=="1"){
$dx=">";
}
elseif($dx=="-1"){
$dx="<";
}
else{
$dx="=";
}
$jg=intval(isset($_POST['jg'])?$_POST['jg']:"");
$lb=isset($_POST['lb'])?$_POST['lb']:"";
if($jdcz!=""){
$sql=mysqli_query($conn,"select * from tb_shangpin where mingcheng like '%".$name."%' order by addtime desc");
}
else
{
if($mh=="1"){
$sql=mysqli_query($conn,"select * from tb_shangpin where huiyuanjia $dx".$jg." and typeid='".$lb."' and mingcheng like '%".$name."%'");
}
else{
$sql=mysqli_query($conn,"select * from tb_shangpin where huiyuanjia $dx".$jg." and typeid='".$lb."' and mingcheng = '".$name."'");
}
}
$info=mysqli_fetch_array($sql);
if($info==false){
echo "<script language='javascript'>alert('本站暂无类似产品!');history.go(-1);</script>";
}
else{
?>
我不大明白这里$mh和$dx的意义?从top.php页面传递过来jdcz和name,就可以完成查询匹配了,为什么还要这两个变量呢?另外,之前没有$mh和$dx,这里是否是在声明变量?
$mh=isset($_POST['mh'])?$_POST['mh']:"";
$dx=isset($_POST['dx'])?$_POST['dx']:"";
另外,$jg和$lb,也是同样的问题?
$jg=intval(isset($_POST['jg'])?$_POST['jg']:"");
$lb=isset($_POST['lb'])?$_POST['lb']:"";
<?php
$jdcz=$_POST['jdcz'];
$name=$_POST['name'];
$mh=isset($_POST['mh'])?$_POST['mh']:"";
$dx=isset($_POST['dx'])?$_POST['dx']:"";
if($dx=="1"){
$dx=">";
}
elseif($dx=="-1"){
$dx="<";
}
else{
$dx="=";
}
$jg=intval(isset($_POST['jg'])?$_POST['jg']:"");
$lb=isset($_POST['lb'])?$_POST['lb']:"";
if($jdcz!=""){
$sql=mysqli_query($conn,"select * from tb_shangpin where mingcheng like '%".$name."%' order by addtime desc");
}
else
{
if($mh=="1"){
$sql=mysqli_query($conn,"select * from tb_shangpin where huiyuanjia $dx".$jg." and typeid='".$lb."' and mingcheng like '%".$name."%'");
}
else{
$sql=mysqli_query($conn,"select * from tb_shangpin where huiyuanjia $dx".$jg." and typeid='".$lb."' and mingcheng = '".$name."'");
}
}
$info=mysqli_fetch_array($sql);
if($info==false){
echo "<script language='javascript'>alert('本站暂无类似产品!');history.go(-1);</script>";
}
else{
?>