PHP mysqli_fetch_row() 函數
從結果集中取得行:
<?php // 假定資料庫用戶名:root,密碼:123456,資料庫:zaixian $con=mysqli_connect("localhost","root","123456","zaixian"); if (mysqli_connect_errno($con)) { echo "連接 MySQL 失敗: " . mysqli_connect_error(); } $sql="SELECT name,url FROM websites ORDER BY alexa"; if ($result=mysqli_query($con,$sql)) { // 一條條獲取 while ($row=mysqli_fetch_row($result)) { printf ("%s : %s",$row[0],$row[1]); echo "<br>"; } // 釋放結果集合 mysqli_free_result($result); } mysqli_close($con); ?>
定義和用法
mysqli_fetch_row() 函數從結果集中取得一行,並作為枚舉數組返回。
語法
mysqli_fetch_row(result);
參數 | 描述 |
---|---|
result | 必需。規定由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 返回的結果集識別字。 |
技術細節
返回值: | 返回一個與所取得行相對應的字串數組。如果在結果集中沒有更多的行則返回 NULL。 |
---|---|
PHP 版本: | 5+ |
