here is the code. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // end headers
//$sql = "SELECT * from orders WHERE status='10' and dealerid >= '1'"; $sql = "select * from dealer, orders where orders.status='10' and orders.dealerid = dealer.dealerid order by orders.dealerid asc"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); echo "table join select statement -> ".$num_rows."\n"; if (!$result) { die('Invalid query: ' . mysql_error()); } if ($num_rows!='0') { //$message ="$num_rows Orders Waiting for the Dealer.\n\n"; //$message .="----------------------------------------------------------------------\n"; while($row = mysql_fetch_array($result)) { $orderid = $row['orderid']; $dealerid = $row['dealerid']; /*$message .="\nOrder #: $orderid | Dealer ID: $dealerid | "; if ($dealerid != NULL && $dealerid != '0') { $sql2 = "SELECT * from dealer WHERE dealerid='".$dealerid."'"; $result2 = mysql_query($sql2); if (!$result) { die('Invalid query: ' . mysql_error()); } $row2 = mysql_fetch_array($result2); $name = $row2['name']; $email = $row2['email']; $surname = $row2['surname']; $company = $row2['company']; $message .="Company: $company | Name: $name $surname | Email: $email\n"; }*/ if ($dealerid != '0' || $dealerid != NULL) { $message .= "$company (DID: $dealerid) has $number_orders waiting for them.\n"; $message .="----------------------------------------------------------------------\n"; $message .= "Contact. $name $surname at $email or $contactday \n"; $message .= "Order #: $orderid \n"; $message .="----------------------------------------------------------------------\n\n\n"; } else { $message .="----------------------------------------------------------------------\n"; $message .= "Order #: $orderid has no dealer information.\n"; $message .="----------------------------------------------------------------------\n\n\n"; } } $message .="\n\n\n"; //$message .="----------------------------------------------------------------------\n"; $datestamp=date("Y-m-d H:i:s"); $message .="Sent on: ".$datestamp."\n"; $title="$num_rows Orders Waiting for the Dealer"; mail($email_address,$title,$message,$headers); } else { $message ="No Orders Waiting for the Dealer.\n\n"; $message .="Sent on: ".$datestamp."\n"; $title="No Orders Waiting for the Dealer"; //mail($email_address,$title,$message,$headers); } ?> <?php function writelog ($logentry, $lgname) { $logfile = @fopen ($lgname, "a+"); if (!$logfile) { echo ("\n\n ERROR: Failed to open $lgname\n\n"); } else { fwrite ($logfile, "[".date ("D M d Y h:i:s")."] [$logentry]\n"); fclose ($logfile); } } ?> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ now as you can see I have a formatted message that I am try to create. what I am trying to do with it is this. Joe's Deli (DID: 123564) has 3 orders waiting for them. ---------------------------------------------------------------------- Contact. Joe Shmoe at [EMAIL PROTECTED] or 610.555.5151 Order #: 2013, 2124, 2158 ---------------------------------------------------------------------- any help? thoughts? --- Greg Donald <[EMAIL PROTECTED]> wrote: > On Fri, 10 Sep 2004 13:33:37 -0700 (PDT), Dan McCullough > <[EMAIL PROTECTED]> wrote: > > 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 > > I'd use a table join with a group by clause. > > > another table) and then go on to the next order and so the same thing all over > > again? > > I'd use a PHP loop construct such as while(). > > What database are you using? What do your tables look like? Where's > the code you've written already if any? > > > -- > Greg Donald > http://destiney.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > ===== -------------------------------------------------------- "Theres no such thing as a problem unless the servers are on fire!" __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php