I do not understand why PHP is trying to pull row 2!!  I want to create an
array of data and construct a table from a query.  The echo of $rows shows 2
rows, so if I'm setting my variable to 0 and incrementing with each loop, it
doesn't make sense to me why it tries to pull row 2.  It should stop at row
1 because the next loop would make the variable 2 and the if says if $ii is
less than 2.

WHAT AM I MISSING!?

I have a while loop written to pull data from a postgreSQL database.  I have
2 and only 2 rows of data in this table.  Probably labeled within PostgreSQL
as '0' and '1'.  The browser displays the error message along with the
proper table listed below it!!

  Warning: Unable to jump to row 2 on PostgreSQL result index 2 in
/var/www/html/steve/frontdoor.php on line 92
   sgaas  Steve  Gaas
      mjohnson  Matt  Johnson




The code is:
<?
$results = pg_exec($link, "select * from users");
 if (!$link) {
  print "Could not connect";
  }

$ii = 0;

$rows = pg_numrows($results);

if ($rows) {
echo "There are $rows rows of data in $localdb";
}

echo "<BR>\n<HR>";
?>

<table>

<?
if ( $ii < $rows) {
 while ($tabledata = pg_fetch_array($results, $ii)) {    <--(LINE 92)

 $username = $tabledata["username"];
 $firstname = $tabledata["firstname"];
 $lastname = $tabledata["lastname"];
 echo "<TR>\n";
 echo "<td>$username</td>\n";
 echo "<td>$firstname</td>\n";
 echo "<td>$lastname</td>\n";
 echo "</tr>\n";
 $ii++;
 }

  }
?>
</table>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to