"Dan McCullough" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I believe that would be the correct term for what I need.
>
> Here is what I have been trying to do.
>
> I have orders and customers.  Customers are required to do a few things
before we can process the
> order.  Some times they are very slow in doing so.  So I wanted to write a
little reminder script
> to poke us to email/call them.
>
> So I have orders and customers.  I need to go through and list out the
orders and then I need to
> use the customer to grab all the order associated with them, then list out
their contact
> information.  Anythough on how I can group orders by customer, list the
customer information (from
> another table) and then go on to the next order and so the same thing all
over again?

Load all customers and while looping through the result set load all orders
associated with the current customer:

// open db connection etc.

// load all customers
$result = mysql_query('SELECT * FROM customers');
while ($row = mysql_fetch_assoc($result)) {

    // output customer data if required
    echo $row['customerName'];

    // load all associated orders
    $tempResult = mysql_query('SELECT * FROM orders WHERE customerID = ' .
$row['customerID']);
    while ($tempRow = mysql_fetch_assoc($result)) {
         // output order data if required
         echo $tempRow['orderID'];
    }
}

Regards, Torsten Roehr

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

Reply via email to