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
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.