Try foreach ($sql_stmt as $row)
... Its easy to handle all your result sets...
Change the database name , user id , table name etc., according to your system
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbConnection= new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$dbConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, TRUE);
$sql_stmt = $dbConnection->prepare($sql_query="select date,price from table;");
$sql_stmt->execute();
foreach ($sql_stmt as $row) {
$date_col=$row['date'];
$price_col=$row['price'];
print $date_col;
print $price_col;
}
If you want to store value in array then use, like below in same foreach loop (declare and increment $i)
$date_col[$i]=$row['date'];
$price_col[$i]=$row['price'];