duplicating mysql_query result

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ciaran

    duplicating mysql_query result

    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_fet ch_array($resul t)) ... loop
    twice and I want to avoid re-runnuing the query.
    Cheers,
    Ciarán

  • =?iso-8859-1?Q?Kim_Andr=E9_Aker=F8?=

    #2
    Re: duplicating mysql_query result

    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_fet ch_array($resul t)) ... loop
    twice and I want to avoid re-runnuing the query.
    Sure thing, just use the mysql_data_seek () function between the while()
    loops, like this:

    while($rowdata = mysql_fetch_arr ay($result)) {
    // do something
    }
    mysql_data_seek ($result, 0);
    while($rowdata = mysql_fetch_arr ay($result)) {
    // do something entirely different
    }



    --
    Kim André Akerø
    - kimandre@NOSPAM betadome.com
    (remove NOSPAM to contact me directly)

    Comment

    • Ciaran

      #3
      Re: duplicating mysql_query result

      On Mar 27, 3:42 pm, Kim André Akerø <kiman...@NOSPA Mbetadome.com>
      wrote:
      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_fet ch_array($resul t)) ... loop
      twice and I want to avoid re-runnuing the query.
      >
      Sure thing, just use the mysql_data_seek () function between the while()
      loops, like this:
      >
      while($rowdata = mysql_fetch_arr ay($result)) {
      // do something}
      >
      mysql_data_seek ($result, 0);
      while($rowdata = mysql_fetch_arr ay($result)) {
      // do something entirely different
      >
      }
      Fantastic! Thanks a lot!
      Ciarán

      Comment

      Working...