pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gavin M. Roy <gmr@ehpg.net>
To: pgsql-php@postgresql.org
Subject: Re: displaying a rowset in php...same column names
Date: Wed, 07 Jan 2004 11:36:09 -0800
Message-ID: <3FFC5FA9.6020604@ehpg.net> (raw)
In-Reply-To: <1073474074.31454.3.camel@skyblue.office.frontsite.com.tr>
References: <71B8A8BEC516CF46835CA629156CF21163F6EE@bedford.idacorp.local>
	<200312291402.35789.scrawford@pinpointresearch.com>
	<EB366B10-40BE-11D8-8D6A-000A95B34330@sympatico.ca>
	<1073474074.31454.3.camel@skyblue.office.frontsite.com.tr>

>
>
>This query: SELECT login, firstname, lastname, date_part('epoch',  
>lastlogin), date_part('epoch', regdate) FROM admin ORDER BY login
>results in:
>
>    login   |    firstname     |    lastname     |    date_part     |     
>date_part
>  
>

Another way from assigning column names, if you dont want to do that...

instead of pg_Fetch_Object

$data = pg_Fetch_Array($result, $row);

/*
$data[0]: login
$data[1]: firstname
$data[2]: lastname
$data[3]: date_part
$data[4]: date_part
*/

*or*

  $login     = pg_Result($result, 0, 0);
  $firstname = pg_Result($result, 1, 0);
  $lastname  = pg_Result($result, 2, 0);
  $date1     = pg_Result($result, 3, 0);
  $date2     = pg_Result($result, 4, 0);

Hope this helps

Gavin

Enver ALTIN wrote:

>On Wed, 2004-01-07 at 05:09, Michael Hanna wrote:
>  
>
>>This query: SELECT login, firstname, lastname, date_part('epoch',  
>>lastlogin), date_part('epoch', regdate) FROM admin ORDER BY login
>>results in:
>>
>>    login   |    firstname     |    lastname     |    date_part     |     
>>date_part
>>    
>>
>
>SELECT foo as bar,bar as foo from footable
>
>notice the "as" thingie. It would help.
>  
>





view thread (4+ messages)

Message-ID: <3FFC5FA9.6020604@ehpg.net>
Permalink:  ../3FFC5FA9.6020604@ehpg.net/
Also on:    postgresql.org/message-id/3FFC5FA9.6020604@ehpg.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: gmr@ehpg.net
  Subject: Re: displaying a rowset in php...same column names
  In-Reply-To: <3FFC5FA9.6020604@ehpg.net>
  References: <71B8A8BEC516CF46835CA629156CF21163F6EE@bedford.idacorp.local> <200312291402.35789.scrawford@pinpointresearch.com> <EB366B10-40BE-11D8-8D6A-000A95B34330@sympatico.ca> <1073474074.31454.3.camel@skyblue.office.frontsite.com.tr> <3FFC5FA9.6020604@ehpg.net>

* 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