Re: Grouped sql output

From: Date: Tue, 26 Feb 2002 10:45:40 +0000
Subject: Re: Grouped sql output
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-17300@lists.php.net to get a copy of this message
Hi Rudi, > I've been struggling for a while now so I thought I'd ask. > What's the easiest way to for to print group sql output. > For example I need to output customers grouped by zip. > Like: > zip > customer a > customer b > zip > customer d > customer e > zip > customer c > custoemr f > customer g > > Do I need to build array's and loop through them or > can I print straight from a record set ( using Postgresql or Mysql ) As a general rule, I would ask the RDBMS to do as much as possible (WHERE, GROUP BY, ORDER BY, HAVING), before handing the data to PHP - then use PHP to concentrate on getting the formatting/presentation (HTML) right! What you're asking for is quite common - and easy to implement (once you know how). Does that 'philosophy' answer your question, or were you wanting coding-level advice? If so, please post your current SQL query and if it's not too long, the pertinent part of your PHP prototype, and I/someone else here, will be happy to make suggestions. Regards, =dn

« previous php.db (#17300) next »