populate php array with while loop? -
is there way output sqlite table php array?
i trying use while loop not display correctly.
$db = sqlite_open ("products.db", 0666, $error); $result=sqlite_query($db,"select * books"); $products = array(); while($row=sqlite_fetch_array($result,sqlite_assoc)) { $products = $row; }
i want store 2d php array if were:
$products = array( 1 => array( 'name' => '', 'price' => , 'category' => '', 'description' => '' ), 2 => array( 'name' => '', 'price' => , 'category' => '', 'description' => '' ), 3 => array( 'name' => '', 'price' => , 'category' => '', 'description' => '' ) );
you're close. need add each row array instead of overwriting array variable doing..
while($row=sqlite_fetch_array($result,sqlite_assoc)) { $products[] = $row; }
Comments
Post a Comment