NYCPHP Meetup

NYPHP.org

[nycphp-talk] php mysql question

Henry Ponce henry at beewh.com
Sat Oct 9 15:51:36 EDT 2004


Brian:

i know this.... and i have no problems doing mysql_num_rows($result) and then 
mysql_fetch_array($result).

My problem is that i want to query the database once. 

I want to be able to reuse the $result in as many mysql_fetch_array($result) 
as i want. Or i want to know if i can copy $result to another variable(s), 
and then do mysql_fetch_array() or mysql_num_rows() or any other possible 
function on the new variable(s).

My question is on how to handle this.

Thanx,
Henry

On Saturday 09 October 2004 16:47, Brian O'Connor wrote:
> If you want to do something along the lines of mysql_num_rows($result)
> then do mysql_fetch_array($result) I don't believe that queries it
> twice, and its the same data.
> 
> 
> On Sat, 9 Oct 2004 14:10:30 -0300, Henry Ponce <henry at beewh.com> wrote:
> > hello people:
> > 
> > i was wondering if someone tell me if this is possible...
> > 
> > i have this:
> > 
> > $q = 'select * from users';
> > $result = mysql_query($q);
> > 
> > There's no problem with that. I want to know if i can do this:
> >         $newresult = $result;
> > 
> > I want to run the query once, but use the result set again. Whenever i do
> > this, $newresult is empty, for example when i place it in:
> >         while ($row = mysql_fetch_array($newresult)){
> > 
> >         }
> > 
> > Can someone tell me the right way of doing this. I don't want to query the
> > database more than once.
> > 
> > Thank you,
> > Henry
> > 
> > _______________________________________________
> > New York PHP Talk
> > Supporting AMP Technology (Apache/MySQL/PHP)
> > http://lists.nyphp.org/mailman/listinfo/talk
> > http://www.newyorkphp.org
> > 
> 
> 
> -- 
> Brian O'Connor
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
> 
> 
> 




More information about the talk mailing list