目前,我的项目有问题。photo before在 MySQL 数据库中,有两个名为photo_afterBLOB的列。base64在将图像显示到 PHP 页面时,我使用它来解码图像。主要问题是列中是否有数据photo_before或者photo_after它仍然显示' noimage.jpg '。我不知道为什么。下面是我的代码:<?php$report_id = $_GET['report_id'];$sql = "SELECT * FROM report LEFT JOIN users ON report.badgeid = users.badgeid LEFT JOIN team ON team.team_id = users.team_id WHERE report_id = :report_id";$query = $conn->prepare($sql);$query->execute(array(':report_id' => $report_id));while($row = $query->fetch(PDO::FETCH_ASSOC)){ $report_id = $row["report_id"]; $report_date = $row["report_date"]; $task_name = $row["task_name"]; $photo_before = $row["photo_before"]; $photo_after = $row["photo_after"]; $ot_start = $row["ot_start"]; $ot_end = $row["ot_end"]; $time_photo_before = $row["time_photo_before"]; $time_photo_after = $row["time_photo_after"]; $report_status = $row["report_status"];}?><tr> <td rowspan = '2'><b>Before Task</b></td> <?php if(!isset($row['photo_before']) || empty($row['photo_before'])) { echo "<td colspan='3'><img src='../../images/faces/noimage.png'/></td>"; }else{ echo "<td colspan='3'><img src='data:image/jpeg;base64,".$row['photo_before']."'/></td>"; } ?></tr><tr> <td colspan='3'><?php echo "Time: <b>" .$time_photo_before."</b>"; ?></td></tr><tr> <td rowspan = '2'><b>After Task</b></td> <?php if(!isset($row['photo_after']) || empty($row['photo_after'])) { echo "<td colspan='3'><img src='../../images/faces/noimage.png'/></td>"; }else{ echo "<td colspan='3'><img src='data:image/jpeg;base64,".$row['photo_after']."'/></td>"; } ?></tr>
2 回答
qq_笑_17
TA贡献1818条经验 获得超7个赞
empty() 函数返回 true 或 false 当变量数据存在并且具有非空、非零值时,它返回 FALSE。否则返回 TRUE。添加并尝试,希望它会工作:
if(!isset($row['photo_after']) || empty($row['photo_after'])== 'true/false')
开心每一天1111
TA贡献1836条经验 获得超13个赞
似乎问题出在 Your 上if( the problem is here )
,|| / 或逻辑发送真如果 0|1,1|0 和 1|1...检查你的 php 版本,".$row['photo_before']."
你的 " 使用 " 或 ',我的使用'.$row['photo_before'].'
- 2 回答
- 0 关注
- 258 浏览
添加回答
举报
0/150
提交
取消