problem using odbc_fetch_row to count rows

From: Date: Thu, 31 Aug 2000 05:00:57 +0000
Subject: problem using odbc_fetch_row to count rows
Groups: php.db 
Request: Send a blank email to php-db+get-2506@lists.php.net to get a copy of this message
Hi all, I am having some trouble resetting odbc_fetch_row. I am using the following code to get the row count: for ($i=0; odbc_fetch_row($this->qry, $i); $i++); $this->rowcount = $i; odbc_fetch_row($this->qry, 1); <<< this should reset it, shouldn't it? However, if I use that, any subsequent calls to odbc_result return the last row (row $i), regardless of what I pass to odbc_fetch_row. The program flow goes like this: while ($db->MoveNext()) { for ($j=1; $j <= $db->GetColumnCount(); $j++) { echo $db->GetValue($j); } } MoveNext basically does $this->row++, and then calls odbc_fetch_row($this->qry, $this->row). $db->GetColumnCount() just returns odbc_result($this->qry, <param>). If there are three rows, what I get is three lots of the last row. If I remove that row counting bit and just hardcode the rowcount into the loop, it works fine. Any clues? Am I missing something dumb, or is PHP not updating the internal row pointer properly? Regards, Tyson Lloyd Thwaites IT&e Ltd

« previous php.db (#2506) next »