PHP PDO Conditional Image ??
I'm trying to elarn PHP PDO - Not sure how to conditionally show the image (blog_img) :
I'm learning PHP PDO - How do you conditionally show an image based on whether it exists? I have the code below at the moment but if no image exists for an article then there's a placeholder for broken image link..
Code:
$ARTICLE = $conn->prepare("SELECT blog_title, blog_article, blog_img FROM Blog WHERE blog_title=:blog_title");
$ARTICLE->bindParam(':blog_title', $blog_title, PDO::PARAM_STR, 25);
$ARTICLE->execute();
<?php
while ($r = $ARTICLE->fetch()) {
?>
<h1>
<?PHP
echo ($r['blog_title']);
?>
</h1>
<img src="images/<?PHP echo ($r['blog_img']);?>">
<?PHP
echo ($r['blog_article']);
?>
<?php
}
?>
