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 .
- PhpMyAdmin .


Php Source Code:


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

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

$pdoQuery = "SELECT * FROM users";

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

$pdoRowCount = $pdoResult->rowCount();

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

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


Share this

Related Posts

Next Post »

Learn Programming Online With: