PHP mysqli_fetch_row() Function
In this chapter you will learn:
- Definition for PHP mysqli_fetch_row() Function
- Syntax for PHP mysqli_fetch_row() Function
- Parameter for PHP mysqli_fetch_row() Function
- Return for PHP mysqli_fetch_row() Function
- Example - fetches one row from a result-set and returns it as an enumerated array
Definition
The mysqli_fetch_row() function fetches one row from a result-set and returns it as an enumerated array.
Syntax
PHP mysqli_fetch_row() Function has the following syntax.
mysqli_fetch_row(result);
Parameter
Parameter | Is Required | Description |
---|---|---|
result | Required. | Result set returned by mysqli_query(), mysqli_store_result() or mysqli_use_result() |
Return
It returns an array of strings that corresponds to the fetched row. NULL if there are no more rows in result set.
Example
Fetches one row from a result-set and returns it as an enumerated array.
<?php//from j a v a 2 s .com
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT name FROM emp";
if ($result=mysqli_query($con,$sql)){
while ($row=mysqli_fetch_row($result)){
printf ("%s (%s)\n",$row[0],$row[1]);
}
mysqli_free_result($result);
}
mysqli_close($con);
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP mysqli_field_count() Function
- Syntax for PHP mysqli_field_count() Function
- Parameter for PHP mysqli_field_count() Function
- Return for PHP mysqli_field_count() Function
- Example - Get the number of columns for the most recent query
Home » PHP Tutorial » PHP MySQLi Functions