displaying a rowset in php...same column names

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



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>
  <?
	}


how do I get this to work? do I need to convert the $row to a 2d php array? How do I do that?

Michael



[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