Looping through a Db query result twice in PEAR

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

 



Greetings All,

I have a problem that I usually solve in MySQL pretty easily, but using PEAR identifiers are not working.
Any suggestions.
I want to loop through a result set in two different while loops that are not nested.

I am able to do in it MySQl as follows

$sql="Some query";
$result = $conn->query($sql);

while ($row = $result->fetchArray()) {
	echo $row['hey'];
}

while ($row2 = $result->fetchArray()) {
	echo $row2['otherhey'];
}

This has worked in the past and I do not have to hit up the DB twice for the same information.

However when I try something similar with PEAR it does not work.
So the below does not work. This is my first time using PEAR.
So can anyone help me out.
I cannot seem to find anything about this on the documentation online.

$sql="Some query";
$result = $db->query($sql);
while($result->fetchInto($data)) {
		echo "\t\t\t<li><a href=\"#$data[id]\">$data[question]</a></li>\n";
}

while($result->fetchInto($data2)) {
		echo "<a name=\"#$data2[id]\">$data2[answer]</a></li>\n";
}

Thanks

Phillip

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux