PDA

Click to See Complete Forum and Search --> : [RESOLVED] fetch associative array for ODBC?


solitario
Jun 17th, 2009, 02:11 PM
Hello all, I normally use this within a function which builds an array:while($row=mysql_fetch_assoc($sql)) {

/* BREAK APART THE KEYS FROM THE VALUES */
foreach($row AS $key=>$value) {

/* ADD TO THE ARRAY */
$array[$i][$key]=$row[$key];

}

/* INCREMENT */
$i++;

}
When the above outputs an array, I normally just type $array[0]['product_description'] or whatever.
Now, I've been told I NEED to use MS Access (yikes), so looking through the PHP manual, I can't find an "odbc_fetch_assoc" function.
Anyone know if there is such a function or perhaps a workaround?
Many thanks.

solitario
Jun 17th, 2009, 02:19 PM
Got it.
odbc_fetch_array requires 2 parameters, so I just put in the increment variable, $i, which I was already using:
while($row=odbc_fetch_array($sql,$i)) {

/* BREAK APART THE KEYS FROM THE VALUES */
foreach($row AS $key=>$value) {

/* ADD TO THE ARRAY */
$array[$i][$key]=$row[$key];

}

/* INCREMENT */
$i++;

}