我在通过php(pdo)选择mysql blob并通过
<img src = "x">
html标记。
这是我目前的代码:
<?php
$db = new Dbh;
$pdo = $db->connect();
$counter = 0;
$content = "";
$statement = $pdo->prepare('SELECT * FROM images');
$statement->execute();
while ($row = $statement->fetch()) {
if (($counter % 3) == 0) { ?>
<div class = "row" style = "width: 99%; margin-left: auto; margin-right: auto;">
<?php } ?>
<div class = "col" style = "padding: 5px;"><a class = "linkImage" href = "#"><img src = "<?php echo $row['image']; ?>" alt = "Bacteria" width = "100%"></a></div>
<?php if (($counter % 3) == 2) { ?>
</div>
<?php }
$counter ++;
}
if (($counter % 3) == 1) { ?>
<div class = "col" style = "padding: 5px;"></div><div class = "col" style = "padding: 5px;"></div></div>
<?php } elseif (($counter % 3) == 2) { ?>
<div class = "col" style = "padding: 5px;"></div></div>
<?php }
?>
因为某些原因html不接受echo
$row['image']
;或者只是
$row['image']
对于img源。