<?php
session_start();
$db=mysqli_connect('localhost','root','root','qa');
$tname=$_POST['teacher'];
$q="select schedule,place from time where Tname='$tname' and Sname is null";
$arr=mysqli_query($db,$q);
echo "您选择了". $tname."老师"."<br/>请继续选择时刻:"."<br/>";
?>
<table border="1" cellspacing="0">
<tr>
<th>时刻:</th>
<th>地点:</th>
</tr>
<?php
while ($result = mysqli_fetch_assoc($arr)) {
?>
<tr>
<td><?php echo $result['schedule']; ?></td>
<td><?php echo $result['place']; ?></td>
</tr>
<?php
}
?>
</table>
<form method="post" action="Stime1.php">
您选择的时间是:<input type="datetime" name="time" />
您的问题是:<textarea name="question"></textarea>
<input type="submit" name="sure" value="确定"/>
</form>
是想选出某个老师没有被选过的时间段,这样的时间段才能显示在页面上让新的同学选择,但是页面上显示什么都没有,但是数据库中是有符合条件的数据项的存在的,然后我先把这个sql语句复制粘贴到数据库中运行,显示的是查询结果为空,然后我上网搜了一下,发现MySQL数据库中有的时候is null是不起作用的,下面是百度到的说法:
最后,把Sname is null改为了Sname=‘ ’,成功的查出了需要的结果,虽然是一个小的知识点,但是还是记一下,免得以后再为这种小错误浪费时间。