X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2B4BBD1D25D for ; Tue, 17 Feb 2004 20:26:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 28820-01 for ; Tue, 17 Feb 2004 16:26:46 -0400 (AST) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 81468D1B49E for ; Tue, 17 Feb 2004 16:26:44 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 1AtBno-000PVP-0X; Tue, 17 Feb 2004 20:26:45 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 056C7163B8; Tue, 17 Feb 2004 20:26:43 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 8BE0015A87; Tue, 17 Feb 2004 20:26:41 +0000 (GMT) From: Richard Huxton To: "lowdog" , Subject: Re: SQL query seach + rearranging results Date: Tue, 17 Feb 2004 20:26:41 +0000 User-Agent: KMail/1.5 References: <004001c3f4a6$fb7ede50$1ec3fea9@rodrigez> In-Reply-To: <004001c3f4a6$fb7ede50$1ec3fea9@rodrigez> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402172026.41114.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/226 X-Sequence-Number: 16916 On Monday 16 February 2004 16:07, lowdog wrote: > hey guys! > > I need your help in writing a php name-day searcher script. Actually, you probably want a mysql list - this is a PostgreSQL list. However, from what I can understand of your problem I think the easiest solution for you might be to order the results by name (nevek table?) and then loop through building a results list while the name remains the same. Something like: $current_name = ''; while (/* fetch next row */) { if ($row['name']==$current_name) { /* add next "day" to output list */ } else { /* display output list if anything there */ $current_name = $row['name']; $output_list = array(); $output_list[] = $row['day']; } } /* on exiting loop, check if there is a final row to display */ Hope that's of some use. PS - indenting your SQL cleanly on multiple lines will save you time in the future - trust me on this. PPS - localization (the accented characters you are having problems with) is a difficult issue, especially on the web where client/page/database encoding can all interact. PPPS - if you port your application to PostgreSQL, you've found the right list for SQL questions. We also have a PHP list and a novice list if you're just starting. Good luck -- Richard Huxton Archonet Ltd