<?php
$con = mysqli_connect('localhost', 'root', '');
if(!$con)
{
die("not ok");
}
mysqli_select_db($con,"uoh");
$q = "SELECT * FROM courses
LEFT JOIN degree_plan ON degree_plan.course_number= courses.course_number
LEFT JOIN student_record ON courses.course_number= student_record.course_number
LEFT JOIN equal ON equal.sn= student_record.sn
AND student_record.id= 201102887
WHERE degree_plan.major='COE';";
$result = mysqli_query($con , $q ) ;
if($result){
echo "<br />";
echo "<table>";
echo "<tr>";
echo "<th>id</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result))
{
if($row["id"]==201102887 || null)
{
echo "<tr>";
echo "<td>" . $row["id"]. "</td>";
echo "</tr>";
}
else
{}
}
echo "</table>";
}
?>
我的程序中有一些代码,它可以工作,但是我有问题,if($row["id"]==201102887 || null)
因为null
尽管null
存在于我的数据库中,但它不接受。
我想这样做,以便如果id
等于201102887
或null
(无值),则执行语句。
您将必须在OR||
的两侧都使用变量。代码应为if($row["id"]==201102887 || $row["id"]== null)
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句