dbarray
Quote
dbarray ( resource $query )
Parameters
query
The result resource that is being evaluated. This result comes from a call to dbquery().
Return Values
Returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows.
If two or more columns of the result have the same field names, the last column will take precedence.
To access the other column(s) of the same name, you either need to access the result with numeric indices by using mysql_fetch_row() or add alias names.
Example
Code
<?php
$result = dbquery(
"SELECT id as userid, fullname, userstatus
FROM sometable
WHERE userstatus = 1"
);
if (dbrows($result)) {
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($data); inside the following loop, you'll
// then create $userid, $fullname, and $userstatus
while ($data = dbarray($result)) {
echo $data["userid"];
echo $data["fullname"];
echo $data["userstatus"];
}
} else {
echo "No data in table.";
}
?>
Here we lists up all the results from "sometable" where userstaus = 1.
Notes
Field names returned by this function are case-sensitive.