1. mysql_fetch_array
2. mysql_fetch_assoc
3. mysql_fetch_object
4. mysql_fetch_row
5. mysql_fetch_field
mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both
while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("ID: %s Name: %s", $row[0], $row[1]); }while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { printf("ID: %s Name: %s", $row["id"], $row["name"]);}mysql_fetch_assoc — Fetch a result row as an associative array
while ($row = mysql_fetch_assoc($result)) { echo $row["userid"]; echo $row["fullname"]; echo $row["userstatus"];} mysql_fetch_field — Get column information from a result and return as an object
$result = mysql_query('select * from table'); $meta = mysql_fetch_field($result); blob: $meta->blobmax_length: $meta->max_lengthmultiple_key: $meta->multiple_key}mysql_fetch_object — Fetch a result row as an object
$result = mysql_query("select * from mytable");while ($row = mysql_fetch_object($result)) { echo $row->user_id; echo $row->fullname;}mysql_fetch_row — Get a result row as an enumerated array
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");if (!$result) { echo 'Could not run query: ' . mysql_error(); exit;}$row = mysql_fetch_row($result);echo $row[0]; // 42echo $row[1]; // the email value
No comments:
Post a Comment