db_fetch_array

5 database.mysqli.inc db_fetch_array($result)
5 database.pgsql.inc db_fetch_array($result)
5 database.mysql.inc db_fetch_array($result)
6 database.mysql.inc db_fetch_array($result)
6 database.pgsql.inc db_fetch_array($result)
6 database.mysqli.inc db_fetch_array($result)

Fetch one result row from the previous query as an array.

Parameters

$result: A database query result resource, as returned from db_query().

Return value

An associative array representing the next row of the result, or FALSE. The keys of this object are the names of the table fields selected by the query, and the values are the field values for this result row.

Related topics

56 calls to db_fetch_array()

File

includes/database.mysql.inc, line 165
Database interface code for MySQL database servers.

Code

function db_fetch_array($result) {
  if ($result) {
    return mysql_fetch_array($result, MYSQL_ASSOC);
  }
}

Comments

Usage example

<?php
$sql
= "select nid from node"; //your select query here
$data = db_query($sql);
// You've now got a database query object.
// To iterate through it use this construct:
while ($item = db_fetch_array($data)) {
 
// Do things to your $item array, which holds all the returned fields for
  // one row of your query.
}
?>

Login or register to post comments