[RESOLVED] fetch associative array for ODBC?
Hello all, I normally use this within a function which builds an array:
PHP Code:
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.
Re: fetch associative array for ODBC?
Got it.
odbc_fetch_array requires 2 parameters, so I just put in the increment variable, $i, which I was already using:
PHP Code:
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++;
}