I'm developing a custom management system with php & mysql and till now I have made the admin panel for inserting posts into the site template but I want to show the users that if the table of blog_posts
is empty ,echo out empty for example & if not then retrieve the data of table & show them to users.
Here's my blog_posts.php page which shows the posts of the table to users:
<div id="box">
<div class="BJadidBold">
<h1><?php echo $title; ?></h1>
<p><?php echo $content; ?></p></br>
</div>
</div>
And this my php_parsers.php which I have included it:
$select_posts = "select * from posts";
$run_posts = mysqli_query($con,$select_posts);
while($row=mysqli_fetch_array($run_posts)){
$id = $row['post_id'];
$title = $row['post_title'];
$date = $row['post_date'];
$author = $row['post_author'];
$image = $row['post_image'];
$keywords = $row['post_keywords'];
$content = $row['post_content'];
}
When I have not inserted any posts from my admin panel ,the blog_posts page will show this notice:
undefined variable: title ...
How to know whether the table is empty or not & if it's empty do something else instead of printing data!