For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > February 2006 > Reusing query result









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Reusing query result
Paddy Joy

2006-02-27, 3:59 am

Hi,

I'm running a query to return the contents of a MySQL table. I need to
be able to use the returned data more than once in my page so instead of
going through each row one by one using mysql_fetch_row() is it possible
to store the result set in a dataset or 2-d table? This way I would only
have to run one query on the database.

Anybody got any ideas on this, is there a standard way of doing this?

thanks,
Paddy
J.O. Aho

2006-02-27, 3:59 am

Paddy Joy wrote:
> Hi,
>
> I'm running a query to return the contents of a MySQL table. I need to
> be able to use the returned data more than once in my page so instead of
> going through each row one by one using mysql_fetch_row() is it possible
> to store the result set in a dataset or 2-d table? This way I would only
> have to run one query on the database.
>
> Anybody got any ideas on this, is there a standard way of doing this?


while ($row = mysql_fetch_array($result)) {
array_push($stack, $row);
}
Stefan Rybacki

2006-02-27, 6:59 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

J.O. Aho schrieb:
> Paddy Joy wrote:
> ...
>
> while ($row = mysql_fetch_array($result)) {
> array_push($stack, $row);
> }


with

stack=array();

;)

Regards
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (MingW32)

iD8DBQFEAyT1yeCLzp/ JKjARAtxmAJ9JcahH4w3A6n2D5hzN3n68libsKgC
dH1sR
9ZlIoa2I5lG0bsUXlZnUzEo=
=NpYt
-----END PGP SIGNATURE-----
Norman Peelman

2006-02-27, 9:56 pm

"Paddy Joy" <patrick.joy2@mail.dcu.ie> wrote in message
news:12051ocrtplbt51@corp.supernews.com...
> Hi,
>
> I'm running a query to return the contents of a MySQL table. I need to
> be able to use the returned data more than once in my page so instead of
> going through each row one by one using mysql_fetch_row() is it possible
> to store the result set in a dataset or 2-d table? This way I would only
> have to run one query on the database.
>
> Anybody got any ideas on this, is there a standard way of doing this?
>
> thanks,
> Paddy


Try this too:

while ($row = mysql_fetch_array($result)) {$data_array[] = $row;}

Norm
---


--
FREE Avatar hosting at www.easyavatar.com


Paddy Joy

2006-02-27, 9:56 pm

Perfect thanks! :-)

Stefan Rybacki wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> J.O. Aho schrieb:
>
> with
>
> stack=array();
>
> ;)
>
> Regards
> Stefan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.1 (MingW32)
>
> iD8DBQFEAyT1yeCLzp/ JKjARAtxmAJ9JcahH4w3A6n2D5hzN3n68libsKgC
dH1sR
> 9ZlIoa2I5lG0bsUXlZnUzEo=
> =NpYt
> -----END PGP SIGNATURE-----

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com