3 回答
TA贡献1827条经验 获得超8个赞
此isset()
函数返回 True/False,因此您不能echo
直接输出值。
所以最好使用单行条件 isset()
就像我在下面写的
echo "<td>" . isset($row['courseid']) ? $row['courseid'] : 'Not Set' . "</td>";
TA贡献1818条经验 获得超8个赞
我重写了你的 while 循环作为例子:
while($row = $result->fetch()){
echo "<tr>";
if (isset($row['courseid'])){
echo "<td>" . $row['courseid']) . "</td>";
} else {
echo "<td>" . 'NOT SET' . "</td>";
}
if (isset($row['enquiryid'])){
echo "<td>" . $row['enquiryid'] . "</td>";
} else {
echo "<td>" . 'NOT SET' . "</td>";
}
if (isset($row['coursename'])){
echo "<td>" . $row['coursename']. "</td>";
} else {
echo "<td>" . 'NOT SET' . "</td>";
}
if (isset($row['courselevel'])){
echo "<td>" . $row['courselevel']) . "</td>";
} else {
echo "<td>" . 'NOT SET' . "</td>";
}
echo "<td>";
echo "<a href='read.php?id=". $row['courseid'] ."' title='View Record' data-toggle='tooltip'><span class='glyphicon glyphicon-eye-open'></span></a>";
echo "<a href='update.php?id=". $row['courseid'] ."' title='Update Record' data-toggle='tooltip'><span class='glyphicon glyphicon-pencil'></span></a>";
echo "<a href='delete.php?id=". $row\'courseid'] ."' title='Delete Record' data-toggle='tooltip'><span class='glyphicon glyphicon-trash'></span></a>";
echo "</td>";
echo "</tr>";
}
希望有帮助
- 3 回答
- 0 关注
- 110 浏览
添加回答
举报