I have a database table name books.Now i need to fetch value from multiple row values (column name position) which contains multiple value separated by comma.Now i need to fetch values from multiple rows into an array using pdo php.
Thanks in advanced
<?php
require_once "includes\config.php";
$sql = 'SELECT * FROM books WHERE shelf_no=2';
$stmt = $db->prepare($sql);
$stmt->execute();
$row = $stmt->fetchALl(PDO::FETCH_ASSOC);
$d = array();
foreach ($row as $value) {
$d[] = explode(",",$value['position']);
}
print_r($d);
?>
and the result is
Array ( [0] => Array ( [0] => b1 [1] => b2 ) [1] => Array ( [0] => a2 [1] => a3 ) )
but i need all values in a single array