Selasa, 20 Oktober 2015

Php : How To Use Pdo Row Count Php

Php Code To Get Count Of Rows In Pdo Result Using Mysql Database


________________________________________________________


In this Php Tutorial we will see How To Use rowCount() To Get Number Of Rows From Pdo Result Using MySQL Database Table With Php .

I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .
- PhpMyAdmin .


 




Php Source Code:

<?php

// PHP PDO Using Row Count
// get number of data in pdo result

try{
    $pdoConnect = new PDO("mysql:host=localhost;dbname=test_db","root","");
} catch (PDOException $ex) {
    echo $ex->getMessage();
    exit();
}

$pdoQuery = "SELECT * FROM users";

$pdoResult = $pdoConnect->query($pdoQuery);

$pdoRowCount = $pdoResult->rowCount();

echo "<h1>$pdoRowCount</h1>";


///////////////OUTPUT:  16



                     

Bagikan

Jangan lewatkan

Php : How To Use Pdo Row Count Php
4/ 5
Oleh

Subscribe via email

Suka dengan artikel di atas? Tambahkan email Anda untuk berlangganan.