ge*********@gmail.com wrote:
I am using a SQL query to pull data that I need for a report. I can get
it to print out just fine on screen, but I can't figure out how to get
the data into an associative array. I have been playing with this for
the past few days and cannot get over the hump on this one.
Can someone please help?
The reason i need to get this data into an associative array is because
the data represents a report I need to export into Excel via the
xlsStream class.
Any help would be much appreciated. I need to get this done for my boss
ASAP.
Thanks.
Which database do you use?
Or do you use an abstractionlayer maybe?
The right answer depends on your circumstances.
eg:
If you use ADODB, try:
$RS = $conn->Execute($someSQL)->getArray();
to make the $RS an assoc array.
(I always do this because it makes the use of the $RS so much more
intuitive.)
If you use ADODB be sure you set the connection-object first in assoc mode,
with something like:
$conn->SetFetchMode(ADODB_FETCH_ASSOC);
From Postgresql:
use pg_fetch_assoc()
etc.
So just look up the corresponding command for you database at
www.php.net.
Regards,
Erwin Moller