Oracle 5.0 Reference Manual page 2281

Table of Contents

Advertisement

Example 20.40.
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("ID: %s
}
mysql_free_result($result);
?>
Example 20.41.
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
printf ("ID: %s
}
mysql_free_result($result);
?>
Notes
See Also
mysql_fetch_row
mysql_fetch_assoc
mysql_data_seek
mysql_query
20.7.2.5.14.
mysql_fetch_assoc
Copyright 1997-2012 the PHP Documentation Group. [2230]
Original MySQL API (Mysql)
mysql_fetch_array
Name: %s", $row["id"], $row["name"]);
mysql_fetch_array
Name: %s", $row[0], $row["name"]);
Performance
An important thing to note is that using
significantly slower than using mysql_fetch_row, while it provides a
significant added value.
Note
Field names returned by this function are case-sensitive.
Note
This function sets NULL fields to the PHP
with
MYSQL_ASSOC
with
MYSQL_BOTH
mysql_fetch_array
NULL
2261
is not
value.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents