X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 3E66CB435BB for ; Thu, 3 Jul 2003 15:42:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 19014-04 for ; Thu, 3 Jul 2003 12:42:35 -0300 (ADT) Received: from tomts16-srv.bellnexxia.net (tomts16.bellnexxia.net [209.226.175.4]) by svr1.postgresql.org (Postfix) with ESMTP id B1D16B438DD for ; Thu, 3 Jul 2003 12:42:34 -0300 (ADT) Received: from acer.sympatico.ca ([65.93.64.14]) by tomts16-srv.bellnexxia.net (InterMail vM.5.01.05.32 201-253-122-126-132-20030307) with ESMTP id <20030703154232.PFJS21124.tomts16-srv.bellnexxia.net@acer.sympatico.ca> for ; Thu, 3 Jul 2003 11:42:32 -0400 Message-Id: <5.2.1.1.0.20030703112719.009ff140@pop6.sympatico.ca> X-Sender: b1wudu74@pop6.sympatico.ca X-Mailer: QUALCOMM Windows Eudora Version 5.2.1 Date: Thu, 03 Jul 2003 11:41:07 -0400 To: pgsql-php@postgresql.org From: Frank Bax Subject: Re: query, display questions In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Archive-Number: 200307/15 X-Sequence-Number: 2127 At 11:19 AM 7/3/03, Michael Hanna wrote: >I have a table: > >michael=# \d healthnotes > Table "public.healthnotes" > Column | Type | Modifiers >--------+-------------------------- >+------------------------------------------------------------- > posted | timestamp with time zone | not null default >('now'::text)::timestamp(6) with time zone > notes | text | >Indexes: healthnotes_pkey primary key btree (posted) > >Often there are multiple entries per day. I want to display the day >once, with all the entries on that day. > >So do I select * from notes and group by date, then write a nested >for-loop in php that ignores the extra timestamp items? Seems a little >inelegant. Or can I select distinct timestamps somehow after converting >them to dates? Retrieve 'posted' as a date *and* a timestamp in the same select: select posted::date as posted_date,* from notes order by date Then do the grouping by date in PHP. >Another question: I want to echo in an html page the timestamp and the >note after it is entered. What php-pgsql commands do this? I think you want to use pg_last_oid to determine the oid of record just inserted, then retrieve it for display? Frank