Hướng dẫn mysqli fetch one row
❮ PHP MySQLi Reference Show Example - Object Oriented styleFetch rows from a result-set: $mysqli = new mysqli("localhost","my_user","my_password","my_db"); if ($mysqli -> connect_errno) { $sql = "SELECT Lastname, Age FROM Persons ORDER BY Lastname"; if ($result = $mysqli -> query($sql)) { $mysqli -> close(); Look at example of procedural style at the bottom. Definition and UsageThe fetch_row() / mysqli_fetch_row() function fetches one row from a result-set and returns it as an enumerated array. SyntaxObject oriented style:$mysqli_result -> fetch_row() Procedural style:Parameter Values
Technical Details
Example - Procedural styleFetch rows from a result-set: $con = mysqli_connect("localhost","my_user","my_password","my_db"); if (mysqli_connect_errno()) { $sql = "SELECT Lastname, Age FROM Persons ORDER BY Lastname"; if ($result = mysqli_query($con, $sql)) { mysqli_close($con); ❮ PHP MySQLi Reference (PHP 4, PHP 5) mysql_fetch_row — Get a result row as an enumerated array Descriptionmysql_fetch_row(resource Parametersresult The result resource that is being evaluated. This result comes from a call to mysql_query(). Return Values Returns an numerical array of strings that corresponds to the fetched row, or mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0. ExamplesExample #1 Fetching one row with mysql_fetch_row()
$row[0]; // 42 Notes
See Also
michael and then an at sign wassupy.com ¶ 19 years ago
a at simongrant dot org ¶ 20 years ago
pepik at gmail dot cz ¶ 9 years ago
'db.php'; larkitetto at gmail dot com ¶ 14 years ago
|