You need to use fetchAll()
$result = $query -> fetchAll();
foreach( $result as $row ) {
echo $row['first_name'];
echo $row['last_name'];
}
More Related Contents:
- Cleansing User Passwords
- How to apply bindValue method in LIMIT clause?
- How to properly set up a PDO connection
- Getting raw SQL query string from PDO prepared statements
- PDO with INSERT INTO through prepared statements [closed]
- Use bound parameter multiple times
- How to replace MySQL functions with PDO?
- How to debug PDO database queries?
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO [duplicate]
- Do SQL connections opened with PDO in PHP have to be closed
- Using value of a column as index in results using PDO
- I’m getting this error code: Invalid argument supplied for foreach() [duplicate]
- PDO and MySQL ‘between’
- PDO Exception Questions – How to Catch Them
- Using PHP data in MySQL [closed]
- Checking the availability of rooms
- PHP PDO prepared statements
- PDO Prepared Inserts multiple rows in single query
- Loading .sql files from within PHP
- mysql PDO how to bind LIKE
- Best way to defend against mysql injection and cross site scripting
- PDO closing connection
- What is PDO & why should I use it?
- PHP: multiple SQL queries in one mysql_query statement
- SQLSTATE[42S22]: Column not found: 1054 Unknown column – Laravel
- Understanding pdo mysql transactions
- Why does this return Resource id #2? [duplicate]
- In PHP with PDO, how to check the final SQL parametrized query? [duplicate]
- PDO::rowCount VS COUNT(*)
- PHP Warning: PHP Startup: Unable to load dynamic library ‘pdo_mysql.so’