如何从mysql表中获取非空值数据

时间:2017-11-14 13:38:53

标签: mysql null

<form action="" method="POST">   <?php  $que = $con->query("SELECT *
FROM ques");       while ($row=mysqli_fetch_array($que)){
          echo "Q.".$row['id'].":".$row['que']."<br>";    echo "<input type='radio'
name='".$row['id']."'value='".$row['ans']."'>".$row['ans']."<br>";
echo "<input type='radio'
name='".$row['id']."'value='".$row['op1']."'>".$row['op1']."<br>";
echo "<input type='radio'
name='".$row['id']."'value='".$row['op2']."'>".$row['op2']."<br>";
echo <input type='radio'
name='".$row['id']."'value='".$row['op3']."'>".$row['op3']."<br>";  }
    ?> <br> <input type="submit" name="sub" value="submit"> </form
> 

1 个答案:

答案 0 :(得分:0)

您需要在查询中添加where子句。

而不是:

SELECT * FROM ques

这样的事情:

SELECT * FROM ques
WHERE yourField is not null

yourField更改为您正在检查的字段。