displaying a rowset in php...same column names - Mailing list pgsql-php

From Michael Hanna
Subject displaying a rowset in php...same column names
Date
Msg-id EB366B10-40BE-11D8-8D6A-000A95B34330@sympatico.ca
Whole thread Raw
In response to Re: SQL convert UTC to MST  (Steve Crawford <scrawford@pinpointresearch.com>)
Responses Re: displaying a rowset in php...same column names
Re: displaying a rowset in php...same column names
List 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
-----------+------------------+-----------------+------------------
+------------------
            | Joe              | Blo             |  1073244631.3063 |
1073244631.3063
  M.too     | Me               | too             | 1073245739.87669 |
1073245739.87669
  admin     | admin first name | admin last name | 1073166434.11792 |
1073166434.11792
  m.four    | Me               | four            | 1073246991.60247 |
1073246991.60247
  m.three   | Me               | three           | 1073246781.73784 |
1073246781.73784
  superuser | admin first name | admin last name | 1073166417.11391 |
1073166417.11391
(6 rows)


with two columns of the same name. how do I reference those columns
individually in PHP 4.32?

One try:


    $query = "SELECT login, firstname, lastname, date_part('epoch',
lastlogin), date_part('epoch', regdate) FROM admin ORDER BY login";
    $result = pg_query($connection, $query) or die("Error in query:
$query. " . pg_last_error($connection));

    $rows = pg_num_rows($result);

    echo $rows;

    //for($i=0; $i<$rows; $i++) {

    //}


    for ($i=0; $i<$rows; $i++)
         {
                 $row = pg_fetch_array($result, $i, PGSQL_ASSOC);
         ?>
        <tr>
         <td width="24%"><? echo $row['login']; ?></td>
         <td width="27%"><? echo $row['firstname']; ?></td>
         <td width="23%"><? echo $row['lastname']; ?></td>

        <?
        //echo $row['lastlogin'];
        $lastlogintime = $row['lastlogin'];
        echo $lastlogintime."<BR><BR>";
        $lastlogintime = strtotime($lastlogintime);
        echo $lastlogintime."<BR><BR>";

        ?>
     <td width="22%"> <!-- want to insert the lastlogin here --></td>
     <td width="4%"><!-- want to insert the regdate here --> </td>
   </tr>
   <?
    }

pgsql-php by date:

Previous
From: Steve Crawford
Date:
Subject: Re: SQL convert UTC to MST
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: displaying a rowset in php...same column names