Search
 
SCRIPT & CODE EXAMPLE
 

PHP

database, counts,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 :: laravel how can I use the same foreign key twice in a single table 
Php :: change verify email template laravel 
Php :: rendering json in laravel 
Php :: php explode empty string 
Php :: update url wordpress 
Php :: php date() 
Php :: How to use Query builder with eloquent in Laravel 8? 
Php :: firstOrFail() 
Php :: error pdo php Exception 
Php :: how to use wherehas in laravel 
Php :: laravel create table if not exists 
Php :: laravel faker 
Php :: php concatenation with a space 
Php :: PHP rtrim — Strip whitespace (or other characters) from the end of a string 
Php :: how to print something in php 
Php :: get users by role name - spatie/laravel-permission 
Php :: do_shortcode not working 
Php :: php json_encode remove array index 
Php :: WordPress Plugin Definition 
Php :: js php number format space 
Php :: console.log for php 
Php :: Alternatively, you may set the environment variables ONIG_CFLAGS and ONIG_LIBS to avoid the need to call pkg-config. 
Php :: no routes.php in http folder 
Php :: remove duplicate characters in a string in php 
Php :: laravel email validation 
Php :: user order by role spatie laravel 
Php :: wpmu create user 
Php :: check mobile number length in php 
Php :: How to Delete Multiple Records using Checkbox in Laravel 
Php :: You need to grant write permissions for PHP on the following directory: /var/www/html/prestashop 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =