I am new at Php and i got this code and if there is no post about selected category i want show warning message. I ve tried "mysqli_num_row" but i did not work. Thank you from now : )
<?php
if(isset($_GET['category'])){
$post_category_id = $_GET['category'];
}
$query = "SELECT * FROM posts WHERE post_category_id = $post_category_id ";
$select_all_posts_query = mysqli_query($connection, $query);
$num_rows = mysqli_num_rows($select_all_posts_query);
if($num_rows.count() < 0){
echo "<h1 class='text-center'>THERE IS NO POST ABOUT THIS CATEGORY!</h1>";
echo "<img style='margin-left:225px;' width='300' class='img-responsive' src='images/sorry.png'/>";
}else{
while($row = mysqli_fetch_assoc($select_all_posts_query)){
$post_id = $row['post_id'];
$post_title = $row['post_title'];
$post_author = $row['post_author'];
$post_date = $row['post_date'];
$post_image = $row['post_image'];
$post_content = substr($row['post_content'], 0, 50);
?>
<h1 class="page-header">
Page Heading
<small>Secondary Text</small>
</h1>
<!-- First Blog Post -->
<h2>
<a href="post.php?p_id=<?php echo $post_id; ?> "><?php echo $post_title ?></a>
</h2>
<p class="lead">
by
<a href="index.php">
<?php echo $post_author ?>
</a>
</p>
<p><span class="glyphicon glyphicon-time"></span>
<?php echo $post_date ?>
</p>
<hr>
<a href="post.php?p_id=<?php echo $post_id; ?>"><img width="600" class="img-responsive" src="images/<?php echo $post_image;?>" alt=""></a>
<hr>
<p>
<?php echo $post_content ?>
</p>
<a class="btn btn-primary" href="#">Read More <span class="glyphicon glyphicon-chevron-right"></span></a>
<hr>
<?php } }?>
These are all my codes.