pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: lowdog <lowdog@axelero.hu>
To: pgsql-sql@postgresql.org
Subject: Re: SQL query seach + rearranging results
Date: Tue, 17 Feb 2004 20:26:41 +0000
Message-ID: <200402172026.41114.dev@archonet.com> (raw)
In-Reply-To: <004001c3f4a6$fb7ede50$1ec3fea9@rodrigez>
References: <004001c3f4a6$fb7ede50$1ec3fea9@rodrigez>

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



view thread (2+ messages)

Message-ID: <200402172026.41114.dev@archonet.com>
Permalink:  ../200402172026.41114.dev@archonet.com/
Also on:    postgresql.org/message-id/200402172026.41114.dev@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, lowdog@axelero.hu
  Subject: Re: SQL query seach + rearranging results
  In-Reply-To: <200402172026.41114.dev@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox