• 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

WHM Enabling mod_rewrite

Store / Website Column in Magento 2 Admin Grid - Custom Module

Not able to override collapsible.js in magento 2

How to edit Records using CodeIgniter

Cannot pass null argument when using type hinting

Laravel 5 issue with wherePivot

unable to load your default controller on Codeigniter

Change the alert text on add to cart action without selected variation in Woocommerce

How to send upload image through email

Submitting a form with ajax in Wordpress

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

PHP Print to Network Printer

Laravel-fopen: failed to open stream: Permission denied

Valet, Xdebug after reboot Big Sur not working

How to make Canonicals with PHP

About Contact Privacy policy Terms and conditions