Skip site navigation (1) Skip section navigation (2)

Re: displaying a rowset in php...same column names

From: "Gavin M(dot) Roy" <gmr(at)ehpg(dot)net>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: displaying a rowset in php...same column names
Date: 2004-01-07 19:36:09
Message-ID: 3FFC5FA9.6020604@ehpg.net (view raw or flat)
Thread:
Lists: pgsql-php
>
>
>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.
>  
>



In response to

pgsql-php by date

Next:From: Mike NolanDate: 2004-01-07 20:45:48
Subject: PHP arrays and postgresql
Previous:From: Enver ALTINDate: 2004-01-07 11:14:34
Subject: Re: displaying a rowset in php...same column names

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group