[PHP] reset a resource?

2006-06-08 Thread sam


After I've looped through a resource do I have to run the query again  
to load up 'mysql_fetch_assoc' or is there some kind of reset  
function I can't find?


$q = SELECT * FROM table;
$s = mysql_query($q, $pe) or die(mysql_error());
while ($row_s = mysql_fetch_assoc($s)) {
echo $i++;
}

outputs 12345... for each row of table


while ($row_s2 = mysql_fetch_assoc($q)) {
...
}

outputs 


Thanks

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



Re: [PHP] reset a resource?

2006-06-08 Thread Brad Bonkoski

Perhaps this will help:
http://www.php.net/manual/en/function.mysql-data-seek.php
-brad

sam wrote:



After I've looped through a resource do I have to run the query again  
to load up 'mysql_fetch_assoc' or is there some kind of reset  
function I can't find?


$q = SELECT * FROM table;
$s = mysql_query($q, $pe) or die(mysql_error());
while ($row_s = mysql_fetch_assoc($s)) {
echo $i++;
}

outputs 12345... for each row of table


while ($row_s2 = mysql_fetch_assoc($q)) {
...
}

and $q is your query, I'm surprised this does not throw an error, unless 
you snipped some other code out of there...



outputs 


Thanks



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



Re: [PHP] reset a resource?

2006-06-08 Thread Ben Liu

sorry, mysql_data_seek()

On 6/8/06, sam [EMAIL PROTECTED] wrote:


After I've looped through a resource do I have to run the query again
to load up 'mysql_fetch_assoc' or is there some kind of reset
function I can't find?

$q = SELECT * FROM table;
$s = mysql_query($q, $pe) or die(mysql_error());
while ($row_s = mysql_fetch_assoc($s)) {
echo $i++;
}

outputs 12345... for each row of table


while ($row_s2 = mysql_fetch_assoc($q)) {
...
}

outputs 


Thanks

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




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