Jump to content

Help with SQL query and associative array


indig0blue

Recommended Posts

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. I am desperate.
Link to comment
https://forums.phpfreaks.com/topic/6977-help-with-sql-query-and-associative-array/
Share on other sites

I was able to get the results to go into an array but now I am only able to get one row of the array in the variable. I need the '$assoc' variable in the code below to hold every row so all the rows will show up in the excel file.

Here is the code i have for this:

$row=0;

while ($row=odbc_fetch_array($sql_result))
{
$ItemNum = $row['ItemNum'];
$Place = $row['Place'];
$QR = 1;
for ($i=0; $i<5; $i++)
{
$assoc = array(array("ItemNum" => $ItemNum, "Place" => $Place, "QR" => $QR));
//echo $assoc;
}
}

Thank you very much in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.