查询结果,如何使用两次? [英] Result of query, how to use twice?

查看:68
本文介绍了查询结果,如何使用两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询结果,并使用此循环获取所有行:

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.


这篇关于查询结果,如何使用两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆