查询结果,如何使用两次?
问题描述:
我有一个查询结果,并使用此循环获取所有行:while( $r = mysql_fetch_array( $res ) )
好的,但是我需要再次获取所有行.
所以我想将查询结果的指针移到顶部并再次重复循环,但是如何?
因此,我必须进行相同的查询,但这不是很好.
I have a result of query and use this cycle for get all rows:while( $r = mysql_fetch_array( $res ) )
OK, but I need get all rows again.
So I want move pointer of result of query to top and repeat cycle again, but how?
So I must make the same query, but this is not good.
答
r = mysql_fetch_array(
r = mysql_fetch_array(
res)))
好的,但是我需要再次获取所有行.
所以我想将查询结果的指针移到顶部并再次重复循环,但是如何?
因此,我必须进行相同的查询,但这并不好.
res ) )
OK, but I need get all rows again.
So I want move pointer of result of query to top and repeat cycle again, but how?
So I must make the same query, but this is not good.
当您通过while循环时,请建立一个关联数组.这样,您可以保存结果以供再次使用,而不必重新查询.
When you go through the while loop, build an associative array. This way you save the results to be used again, and don''t have to re-query.