Reset Informix Fetch Row
| From: | Dan Fitzpatrick | Date: | Sun, 09 Jul 2000 02:38:30 +0000 |
| Subject: | Reset Informix Fetch Row | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-984@lists.php.net to get a copy of this message | ||
How do you reset an IFX_FETCH_ROW to start at row 0 after already
looping through the query results? I want to display a table of contents
menu for a page. Then loop through the same query to output the actual
body of each record. I could set a variable in the initial loop that
would be the content of the output for what would have been that second
loop, but I don't know if that is the most efficient solution.
Example:
// Query results = 10 records with the fields: recordid, title, body
// Output a table of contents for the page
echo "<ul>";
while ($row = ifx_fetch_row($results)) {
$id = $row[recordid];
$title = $row[title];
echo "<li><a href=#a$id>$title</a>\n";
}
echo "</ul><hr>";
// This is what I use in MySQL
mysql_data_seek ($results, 0); // How do you do this with Informix?
// Output the same query with the anchor, title, and body of the content
while ($row = ifx_fetch_row($results)) {
$id = $row[recordid];
$title = $row[title];
$body = $row[body];
echo "<a
name=a$id></a><br><b>$title</b><br>$body<br><br>\n";
}
Thanks,
Dan