• 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

Wordpress add responsive srcset header image to theme

Call to undefined function openssl_decrypt

How to get transaction details in notify_url page in paypal

Phalcon: setStatusCode returns empty response

mysql_result is defined but mysql_free_result warns it expected a resource

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

I cannot create a auto generated date time in mysql workbench

How do I call a php file with axios?

Having issue with matching rows in the database using PDO

How to make dot match newline characters using regular expressions

Laravel Pagination links() not working

Get latest Tweets - What API

how to see if database exists with PDO [duplicate]

How to make a array inside array?

Creating command to backup MySql database in Laravel

About Contact Privacy policy Terms and conditions