Hướng dẫn mysql_fetch_array vs mysql_fetch_row - mysql_fetch_array so với mysql_fetch_row

(Php 4, Php 5)

mysql_fetch_row - Nhận một hàng kết quả như một mảng được liệt kêGet a result row as an enumerated array

Sự mô tả

mysql_fetch_row (tài nguyên $result): mảng(resource $result): array

Thông số

result

Tài nguyên kết quả đang được đánh giá. Kết quả này đến từ một cuộc gọi đến mysql_query ().resource that is being evaluated. This result comes from a call to mysql_query().

Trả về giá trị

Trả về một mảng số của các chuỗi tương ứng với hàng được tìm nạp hoặc false nếu không có hàng.false if there are no more rows.

mysql_fetch_row () lấy một hàng dữ liệu từ kết quả được liên kết với định danh kết quả được chỉ định. Hàng được trả lại dưới dạng một mảng. Mỗi cột kết quả được lưu trữ trong một phần bù mảng, bắt đầu ở độ lệch 0. 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.

Ví dụ

Ví dụ #1 Tìm nạp một hàng với mysql_fetch_row ()mysql_fetch_row()

$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]; // 42
echo $row[1]; // the email value
?>

Ghi chú

Lưu ý: Hàm này đặt các trường NULL thành giá trị PHP null.: This function sets NULL fields to the PHP null value.

Xem thêm

  • mysql_fetch_array () - lấy hàng kết quả như một mảng kết hợp, một mảng số hoặc cả hai
  • mysql_fetch_assoc () - lấy hàng kết quả như một mảng kết hợp
  • mysql_fetch_object () - tìm nạp một hàng kết quả như một đối tượng
  • mysql_data_seek () - di chuyển con trỏ kết quả nội bộ
  • mysql_fetch_lengths () - Nhận độ dài của mỗi đầu ra trong một kết quả
  • mysql_result () - Nhận dữ liệu kết quả

Michael và sau đó là một dấu hiệu Wassupy.com

19 năm trước

to print an array, simply use print_r(array name)

like this:
    $myrow = mysql_fetch_row($result);
echo "

";
print_r($myrow);
echo "
";

this will output the array in a readable form, with the index, too. Don't forget the 'pre' tags or the output will be on a single line.

result0

A tại simongrant dot org ¶

20 năm trước

result1

Pepik tại gmail dot cz ¶

9 năm trước

result2

result3

result4

Larkitetto tại Gmail Dot Com ¶

14 năm trước

result5

result6

result0