Amit Dhamu

Software Engineer

Simple Select Query with PDO

$connection = new PDO("mysql:host=localhost;dbname=database1", $username, $pass);

$select_books = $connection->query('SELECT * FROM books');

// Num of records
$select_books->rowCount();

// Associate array of all results
$select_books->fetchAll();

// To loop through the results
while ($books = $select_books->fetch()) {
    echo $books['title'] . '<br>';
}

 mysql / query / select / pdo

Query Fetch Types in PDORemove Empty Lines In SublimeText

Show Comments

Made with by Amit Dhamu.
© MMXX. All rights reserved.