Re: query, display questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux