ฟังก์ชัน mysql_fetch_lengths() ของ PHP

คำอธิบายและวิธีใช้

ฟังก์ชัน mysql_fetch_lengths() จะกู้ค่าความยาวของแต่ละลูกของในบรรทัด

บรรทัดถูกกลับโดยฟังก์ชันตัวนี้:mysql_fetch_array()mysql_fetch_assoc()mysql_fetch_object() หรือ mysql_fetch_row()

ถ้าประสบความสำเร็จ ฟังก์ชันนี้จะกลับค่าเป็นอาเรียย์เลขาศัพท์ ถ้าเกิดข้อผิดพลาดหรือไม่มีบรรทัดอื่น จะกลับค่า false。

ภาษา

mysql_fetch_lengths(data)
ตัวแปร รายละเอียด
data จำเป็น ความหมายของแสงแห่งข้อมูลที่จะใช้ แสงแห่งข้อมูลนี้มาจาก mysql_query() ผลลัพธ์ที่กลับมา

ตัวอย่าง

<?php
$con = mysql_connect("localhost", "peter", "abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname='Refsnes'";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_row($result));
print_r(mysql_fetch_lengths($result));
mysql_close($con);
?>

ออกแสดง:

Array
(
[0] => Adams
[1] => John
[2] => London
)
Array
(
[0] => 5
[1] => 4
[2] => 6
)