Welcome Guest, Not a member yet? Register   Sign In
JOIN problem
#13

[eluser]underzen[/eluser]
[quote author="Dyllon" date="1262947180"]Just foreach through the array to group your orders.

Code:
$query_result = array(
          array(
             'id' => 84,
             'order_date' => '2010-01-04 15:07:00',
             'order_id' => 84,
             'product_id' => 1
            ),
          array(
             'id' => 84,
             'order_date' => '2010-01-04 15:07:00',
             'order_id' => 84,
             'product_id' => 3
            ),
          array(
             'id' => 85,
             'order_date' => '2010-01-07 13:24:02',
             'order_id' => 85,
             'product_id' => 1
            )
        );

$orders = array();
foreach($query_result as $order)
{
    $orders[$order['id']][] = $order;
}
print_r($orders);
gives this result
Code:
Array
(
    [84] => Array
        (
            [0] => Array
                (
                    [id] => 84
                    [order_date] => 2010-01-04 15:07:00
                    [order_id] => 84
                    [product_id] => 1
                )

            [1] => Array
                (
                    [id] => 84
                    [order_date] => 2010-01-04 15:07:00
                    [order_id] => 84
                    [product_id] => 3
                )

        )

    [85] => Array
        (
            [0] => Array
                (
                    [id] => 85
                    [order_date] => 2010-01-07 13:24:02
                    [order_id] => 85
                    [product_id] => 1
                )

        )

)
[/quote]



Dyllon,

I can't believe it was that easy and that I couldn't figure it out myself...Work's perfectly. Smile

Sorry for taking a long time to respond but I've been out of town. Thank you to everyone, you all are life savers!!!!!!

KUDOS!!!!


Messages In This Thread
JOIN problem - by El Forum - 01-07-2010, 03:12 PM
JOIN problem - by El Forum - 01-07-2010, 03:55 PM
JOIN problem - by El Forum - 01-07-2010, 04:00 PM
JOIN problem - by El Forum - 01-07-2010, 04:03 PM
JOIN problem - by El Forum - 01-07-2010, 04:07 PM
JOIN problem - by El Forum - 01-07-2010, 08:22 PM
JOIN problem - by El Forum - 01-07-2010, 09:29 PM
JOIN problem - by El Forum - 01-07-2010, 10:39 PM
JOIN problem - by El Forum - 01-08-2010, 07:52 AM
JOIN problem - by El Forum - 01-09-2010, 12:18 AM
JOIN problem - by El Forum - 01-09-2010, 01:55 PM
JOIN problem - by El Forum - 01-09-2010, 02:18 PM
JOIN problem - by El Forum - 01-10-2010, 10:34 AM
JOIN problem - by El Forum - 01-10-2010, 10:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB