• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Check for PDO Results, If None Display Message, If Yes then Loop Through

phppdo


PHP Snippet 1:

$results = $stm->fetchAll();
if(empty($results))//or  if(!$results)  or  if(count($results)==0)  or if($results == array())
{
    echo 'Nothing found';
}
else
{
    foreach($results as $result)
    {
        //do stuff
    }
}

PHP Snippet 2:

$stm->execute();

if($stm->rowCount() == 0)
{
    echo 'Nothing found';
}
else
{
    //do your stuff
}

Related Snippets

How to fix bootstrap multiselect search data using ajax

using random function but it's displaying duplicates

"There is no active transaction" when refreshing database in Laravel 8.0 test

Laravel 8 Multiple Relationships for Factory

how to remove white space in select 2

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

I want to display default profile image if user do not have profile image

VB.NET WebRequest with PHP POST

How can I access an array/object?

I'm trying to use curl with php but getting this error:Could not resolve host: Bearer

PHP - Store information with NO database

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

How to remove index.php and index from the URL using htaccess | PHP

Laravel - How to properly generate unique slugs from article titles?

Attempted to call an undefined method named "get" of class "MailController"

About Contact Privacy policy Terms and conditions