目前,我的项目有问题。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>
qq_笑_17
开心每一天1111