Array help. Looking for a better way
<p><strong>EDIT::
Maybe I should be asking what the proper way to get a result set from the database is. When you have 5 joins where there is a 1:M relationship, do you go to the database 5 different times for the data??</strong></p>

<p>I asked this question about an hour ago but haven't been able to get an answer that was fitting. I went ahead and wrote some code that does exactly what I need but am looking for a better way to do it</p>

<p>This array gives me multiple rows of which only some are needed once and others are needed many times. I need to filter these as I have done below but want a better way of doing this if possible.</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [cid] =&gt; one line
            [model] =&gt; one line
            [mfgr] =&gt; one line
            [color] =&gt; one line
            [orderid] =&gt; one line
            [product] =&gt; many lines
            [location] =&gt; many lines
        )
    [1] =&gt; Array
        (
            .. repeats for as many rows as were found
        )
)
</code></pre>

<p>This code works perfectly but again, I think there is a more efficient way of doing this. Is there a PHP function that will allow me to clean this up a bit?</p>

<pre><code>    // these are the two columns that produce more than 1 result.
    $product = '';
    $orderid = '';

    foreach($res as $key)
    {
        // these produce many results but I only need one.
        $cid = $key['cid'];
        $model = $key['model'];
        $mfgr = $key['mfgr'];
        $color = $key['color'];
        $orderid = $key['orderid'];

        // these are the two columns that produce more than 1 result.
        if($key['flag'] == 'product')
        {
            $product .= $key['content'];
        }
        if($key['flag'] == 'orderid')
        {
            $orderid .= $key['content'];
        }
    }

// my variables from above in string format:
</code></pre>

<hr>

<p>Here is the requested SQL</p>

<pre><code>SELECT
cid,
model,
mfgr,
color,
orderid,
product,
flag
FROM products Inner Join bluas ON products.cid = bluas.cid
WHERE bluas.cid = 332
ORDER BY bluas.location ASC
</code></pre>
