For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > March 2007 > duplicating mysql_query result









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author duplicating mysql_query result
Ciaran

2007-03-27, 7:00 pm

Hi is there a way of duplicating the same mysql_query resource result
or is there a way to stop it from being cleared once it is no longer
needed? I need to run a ... while(mysql_fetch_array($result)) ... loop
twice and I want to avoid re-runnuing the query.
Cheers,
Ciar=E1n

Kim André Akerĝ

2007-03-27, 7:00 pm

Ciaran wrote:

> Hi is there a way of duplicating the same mysql_query resource result
> or is there a way to stop it from being cleared once it is no longer
> needed? I need to run a ... while(mysql_fetch_array($result)) ... loop
> twice and I want to avoid re-runnuing the query.


Sure thing, just use the mysql_data_s() function between the while()
loops, like this:

while($rowdata = mysql_fetch_array($result)) {
// do something
}
mysql_data_s($result, 0);
while($rowdata = mysql_fetch_array($result)) {
// do something entirely different
}

[url]http://php.net/mysql_data_s[/url]

--
Kim André Akerĝ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Ciaran

2007-03-27, 7:00 pm

On Mar 27, 3:42 pm, Kim Andr=E9 Aker=F8 <kiman...@NOSPAMbetadome.com>
wrote:
> Ciaran wrote:
>
> Sure thing, just use the mysql_data_s() function between the while()
> loops, like this:
>
> while($rowdata =3D mysql_fetch_array($result)) {
> // do something}
>
> mysql_data_s($result, 0);
> while($rowdata =3D mysql_fetch_array($result)) {
> // do something entirely different
>
> }


Fantastic! Thanks a lot!
Ciar=E1n

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com