Use query twice mysql_fetch_array

后端 未结 5 1923
忘了有多久
忘了有多久 2020-12-29 06:06

a simple

$stuff = mysql_query(\"SELECT * FROM users\");

while($s = mysql_fetch_array($stuff)){
# ....
}

while($r = mysql_fetch_array($stuff)){
# ...
}
         


        
5条回答
  •  佛祖请我去吃肉
    2020-12-29 06:39

    $stuff = mysql_query("SELECT * FROM users");
    
    while($s = mysql_fetch_array($stuff)){
    # ....
    }
    // add this line
    mysql_data_seek( $stuff, 0 );
    
    while($r = mysql_fetch_array($stuff)){
    # ...
    }
    

    Should do the trick

    Another way is of course to store your result in an array and reuse that

提交回复
热议问题