• 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 load Codeigniter 4 lang file into an array variable

Adding multiple items to WooCommerce cart at once

Log file is not being written in Laravel 5.5

how to validate form data in codeigniter 4

Sum column values from multiple arrays

How can I pass the list to the component variable in Laravel?

I cannot create a auto generated date time in mysql workbench

Doctrine 2 mapping referencing unique key

Merge column values from two arrays to form an indexed array of associative arrays

Laravel insert dynamic input values with radio button

PHP Print to Network Printer

HTML and PHP in one file

GA4 custom event from server side, can someone tell me how i can do the following code in php?

Laravel Carbon throws error The format separator does not match

Shortcode or PHP inside a shortcode in Wordpress

About Contact Privacy policy Terms and conditions