how to count specific coumns row data in mysql without any conditons in php pdo?
Get the solution ↓↓↓I have table "POST_DATA" and consists of total (13) fields. like userID, user_name,pass, cam_name,cam_model etc.. whenever a user registers on my website some fields get updated like (userid,user_name,pass) and other fields are empty. But the problem is when I retrieve data from another PHP file using rowcount() on specific columns it returns "1" every time, I want to "0" if no data found on that specific fields like(cam_img,cam_name,cam_model etc..) still it not get updated. what is the problem...
here is my code:
$stmt = $index_home->getDetails();
if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>
<div class="row">
<div class="span9" style="float:right;">
<ul class="thumbnails list row" style="display:block;" >
<li>
<div class="thumbnail">
<div class="row">
<div class="span3"> <span class="sale tooltip-test"> <i class="icon-gift font24"></i> <br>
New</span> <a href="#"><img alt="" src="user_images/<?php echo $row['cam_img']; ?>"></a>
</div>
<div class="span6"> <span class="prdocutname" style="font-size:20px;" ><?php echo ucfirst($cam_name) ." " .$cam_model?></span></div>
<div class="span6"> <span class="prdocutname" ><?php echo "Rent: " . $cam_rent . "/- (per day)"?></span></div>
<div class="span6"> <span class="prdocutname" ><?php echo "Mobile: " . $mobile ?></span></div>
<div class="span6">
<button data-original-title="Cart" class="btn btn-orange tooltip-test"> <i class="icon-shopping-cart icon-white"></i> </button>
<button data-original-title="Wishlist" class="btn btn-orange btn-small tooltip-test"> <i class="icon-heart icon-white"></i> </button>
<button data-original-title="Compare" class="btn btn-orange btn-small tooltip-test"> <i class="icon-refresh icon-white"></i> </button>
</div>
<a href="#" onclick="window.open('view_item.php?id=<?php echo $row['userID']; ?>')" class="btn btn-orange btn-small addtocartbutton">Detail view</a> </div>
</div>
</div>
</li>
</ul>
</div>
<?php
}
}
else
{
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
And getDetails() implementation in USER class
public function getDetails()
{
try
{
$stmt = $this->conn->prepare('SELECT userID, user_name, cam_name, cam_model, cam_rent, cam_img, mobile FROM post_data ORDER BY userID DESC');
$stmt->execute();
return $stmt;
}
catch(PDOException $ex)
{
echo $ex->getMessage();
}
}
I want to restrict rowCount() to return "1" if no data found in that particular columns.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: using $this when not in object context laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.