Re: multi dimension array
| From: | Torsten Roehr | Date: | Fri, 10 Sep 2004 20:51:57 +0000 |
| Subject: | Re: multi dimension array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196362@lists.php.net to get a copy of this message | ||
"Dan McCullough" <McWC@rocketmail.com> wrote in message
news:20040910203338.66785.qmail@web11808.mail.yahoo.com...
> 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