Sunday, 18 August 2013

mysqli show "no results found"

mysqli show "no results found"

I would like to show "no results found" if there are no rows matching the
query. i I have tried:
if(!$result) {echo"no results found";}
and
if($stmt->num_rows < 1) {echo"no results found"}
but none of them work. What is a correct procedure?
$stmt = $mydb->prepare("SELECT * FROM messages where from_user = ? and
deleted = 'yes' ");
$stmt->bind_param('ss', $username->username, $username->username);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo $row['message'];}

No comments:

Post a Comment