mysql_fetch_row()
array mysql_fetch_row(results)This function returns an array containing a row of data from
a results set given. This function is typically used in conjunction
with a loop statement to retrieve each row of data in a results set.
Each loop retrieves the next row. Individual fields appear in the
array in the order they appeared in the SELECT
statement, and can be retrieved by an array index. The loop ends when
rows are used up because the function returns NULL. Here is an
example:
...
$sql_stmnt = "SELECT wr_id, client_name, description
FROM workreq, clients
WHERE workreq.clientid = clients.clientid";
$results = mysql_query($sql_stmnt);
while($row = mysql_fetch_row($results)) {
print "WR-$row[0]: $row[1] - $row[2] \n";
}
...To get the data for each element of the $row
array created by mysql_fetch_row(), you must
know the number corresponding to each element. The index of the
elements begins with 0, so $row[0] is the first
element and, in this case, the work request number because
wr_id was the first field requested by the
SELECT statement. Here’s one line of the output
from this script:
WR-5755: Farber Investments - Can't connect to Internet.