Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

database, counts

// 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);
 
PREVIOUS NEXT
Tagged: #counts
ADD COMMENT
Topic
Name
7+1 =