Heim > Artikel > Backend-Entwicklung > php 值传递后查找数据库找不到
做一个简单的学生管理系统
专业:
至少要这样
$query = "select * from s where pro='$pro'";
贴出你的代码看看啦
至少要这样
$query = "select * from s where pro='$pro'";
结果是一样的无法匹配到 单独显示$pro都有值
贴出你的代码看看啦
if (!empty($_POST["sname"]))
{
$sname = $_POST["sname"];
}
else
{$sname="空";}
if (!empty($_POST["sid"]))
{
$sid=$_POST["sid"];
}
else
{$sid="空";}
$pro = $_POST["pro"];
$grade=$_POST["grade"];
$class=$_POST["class"];
?>
if ($grade =="全部" && $class =="全部" && $pro=="全部" && $sname=="空" && $sid=="空" )
{
$query = "select * from s order by sid desc";
}
else if ($grade =="全部" && $class =="全部" && $pro=="全部" && $sname!="空" && $sid=="空" )
{
$query = "select * from s where sname=$sname order by sid desc";
}
else if ($grade =="全部" && $class =="全部" && $pro=="全部" && $sname=="空" && $sid!="空" )
{
$query = "select * from s where sid=$sid order by sid desc";
}
else if ($grade =="全部" && $class =="全部" && $pro=="全部" && $sname!="空" && $sid!="空" )
{
$query = "select * from s where sid=$sid and sname=$sname order by sid desc";
}
else if ($grade =="全部" && $class =="全部" && $pro!="全部" && $sname=="空" && $sid=="空" )
{
$query = "select * from s where pro=$pro order by sid desc";
}
$result = $db->query($query);
if ($result >0) {
while ($row = $result->fetch_assoc()) {
?>
专业:
至少要这样
$query = "select * from s where pro='$pro'";
可以了 多谢