• 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 change HTML structure inside WP <head>

CONCAT columns with Laravel 5 eloquent

Php - Sum up the numbers in an array one by one

html-php form submission after validation through JavaScript [closed]

Laravel 5 session not persisting after user is logged in

Add custom text under order details on WooCommerce My account view order pages

What will the best solution for this multiple optional filter?

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

Get data from accuweather api url

Get WooCommerce product variation attribute terms in admin products general box

Convert regular text to array using notepad++

browsersync doesn't work with XAMPP

get attribute from class not working php 7

Dynamic table in HTML using MySQL and php

Composer fails with kylekatarnls/update-helper on new homestead

About Contact Privacy policy Terms and conditions