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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -