Search
 
SCRIPT & CODE EXAMPLE
 

PHP

How to show total count in tables using php

// With this php function you will be able to fetch all the number of items from a database table
// if this was helpful to you don't forget to follow

function showCon($pdo){
    try {
        $pdo= new PDO('mysql:host=localhost;dbname=database_name;charset=utf8','username','password');
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $pdo = $pdo->prepare("SELECT COUNT(*) FROM `database_table`");
        $pdo->execute();
        $row = $pdo->fetch();
        return $row[0];
      

    } catch (PDOException $e) {
       echo "Fatal Error: " . $e->getMessage();
    }
}
echo showCon($pdo);
Comment

PREVIOUS NEXT
Code Example
Php :: number data type in laravel migration 
Php :: global variable in laravel controller 
Php :: get array of last 3 dates with carbon 
Php :: woocommerce disable links on specific product 
Php :: php select using prepared statements 
Php :: laravel blade array seearch select box 
Php :: how to use union and intersection in laravel query 
Php :: determine if file is empty in php 
Php :: if statement in laravel blade 
Php :: laravel basic login 
Php :: customize laravel pagination links 
Php :: how to create cookie in laravel 
Php :: lastinsertId php 
Php :: return back laravel controller 
Php :: php explode sentence into words 
Php :: laravel api 
Php :: get current user in symfony 
Php :: laravel where and blade 
Php :: PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting 
Php :: number text short in laravel 
Php :: laravel migration text length 
Php :: Show All Categories as Links 
Php :: php foreach json object 
Php :: create config value file in php 
Php :: php assign an array inside a foreach loop 
Php :: laravel get url parameter value in controller 
Php :: php get today at 3pm 
Php :: limit wordpress search to title 
Php :: what is carriage return in php 
Php :: Wordpress pagination custom arrow 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =