• 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

Timber: Single post pagination does not work (wp_link_pages)

PHP array_filter with arguments

Insert database rows from columns of data from associative array of indexed arrays

how to upload binary image to sql server using php laravel

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

Valet, Xdebug after reboot Big Sur not working

How to display table header in every page using FPDF library?

laravel sanctum Route [login] not defined

Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

PHPSpreadsheet - How Do I Use Auto Migration Tool

How do I call Validator from a namespace with an already existing Validator class

Make Calculator - When Button clicked the No shows in Textbox.

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

Correctly determine if date string is a valid date in that format

how to fix Service provider class not found when using repository?

About Contact Privacy policy Terms and conditions