|
-
Jun 17th, 2009, 02:11 PM
#1
Thread Starter
Lively Member
[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.
Last edited by solitario; Jun 17th, 2009 at 02:20 PM.
Reason: [RESOLVED]
-
Jun 17th, 2009, 02:19 PM
#2
Thread Starter
Lively Member
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++;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|