> -----Original Message-----
> From: Jason Barnett [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 30, 2004 11:41 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: multi-dimentional array from db results
> 
> 
> Motorpsychkill wrote:
> 
> > I'm trying to re-create the following multi-dimentional array from a
> > database query, where the indices 5, 7 and 21 are "order_id" 
> and my table is
> > 
> > food_orders(order_id, food, cooked):
> > 
> > <?php
> > $food_array = array(
> >                     5=>array('steak','rare'),
> >                     7=>array('burger','medium'),
> >                     21=>array('lamb_chops','well'),
> > );
> > 
> > 
> > $query = "select * from food_orders where date = NOW()";
> > $result = mysql_query($query);
> > 
> > while($row = mysql_fetch_array($result)){
> > 
> >     $food_array[$row['order_id']] .= array($row['food'], 
> $row['cooked']);
> 
> The .= operator is for concatenating strings.  The above code block adds 
> the result of array($row['food'], $row['cooked']) to a blank string.  If 
> you are trying to assign array variables you want to use
> 
> $food_array[$row['order_id']] = array($row['food'], $row['cooked']);
> 

Thanks dude, I've wasted a couple of hours on that :)

-m 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to