How to Store Multiple Query in Array |
Hello All,
i have been doing some practice with codeigniter ( as i am new) , actually i wanted to do something like cart, first of all i want to pass a product id parameter then the model would send a return query which would be displayed in cart. the problem is i want to display multiple products, so the question is how can i store the return query and display all the selected query at once ? ( i am totally newbie , but here are my code below!! Controller function Code: public function addtocart($pid) Model Function Code: public function in_cart($pid) View : Code: <?php to make it clear , i wanna click on add to cart(button) so that the product is added to cart, but the thing i couldnt figure out is, how to store multiple query so that i can display it in a view.
Maybe you should use the Shopping Cart Class from CI:
http://www.codeigniter.com/userguide3/li.../cart.html
$data = array(
array( 'id' => 'sku_123ABC', 'qty' => 1, 'price' => 39.95, 'name' => 'T-Shirt', 'options' => array('Size' => 'L', 'Color' => 'Red') ), array( 'id' => 'sku_567ZYX', 'qty' => 1, 'price' => 9.95, 'name' => 'Coffee Mug' ), array( 'id' => 'sku_965QRS', 'qty' => 1, 'price' => 29.95, 'name' => 'Shot Glass' ) ); how can i store my query results in this array ? that is my question
How does your query result looks like? show me the print_r() of the result data.
(11-20-2014, 01:24 PM)niires1204 Wrote: how can i store my query results in this array ? that is my question Yes, like bclinton advises, use PHP Code: //return $query->result(); Code: array PHP Code: $data[] = $query[0]; PHP Code: <?php |
Welcome Guest, Not a member yet? Register Sign In |