Reusing query result
am 27.02.2006 05:58:49 von Paddy Joy
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
Re: Reusing query result
am 27.02.2006 08:26:55 von Shion
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);
}
Re: Reusing query result
am 27.02.2006 17:12:37 von Stefan Rybacki
-----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/JKjARAtxmAJ9JcahH4w3A6n2D5hzN3n68libsKgCd H1sR
9ZlIoa2I5lG0bsUXlZnUzEo=
=NpYt
-----END PGP SIGNATURE-----
Re: Reusing query result
am 28.02.2006 03:52:27 von Norman Peelman
"Paddy Joy" 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
Re: Reusing query result
am 28.02.2006 04:01:07 von Paddy Joy
Perfect thanks! :-)
Stefan Rybacki wrote:
> -----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/JKjARAtxmAJ9JcahH4w3A6n2D5hzN3n68libsKgCd H1sR
> 9ZlIoa2I5lG0bsUXlZnUzEo=
> =NpYt
> -----END PGP SIGNATURE-----