Mysql
Function: mysql_fetch_array()
function: mysql_fetch_array ( result, type );
return
type: array
content: ใช้คืนค่า ค่าข้อมูล ของ result
ในแถวที่ชี้อยู่ และเก็บไว้ที่ array และเลื่อนไปตัวชี้ชี้ไปยังตำแหน่งถัดไป
โดย
array
ที่ได้มี key คือคอลัมน์ที่หรือชื่อฟิลด์ โดยจะคืนค่า false ถ้าเกิดความผิดพลาดขึ้น
example: $conn = mysql_connect (
"localhost", "root", "1234" );
$sql
= "SELECT * FROM employee INNER JOIN position ON employee.position_id =
position.id";
$result
= mysql_db_query ( "dblabcode", $sql, $conn );
while
( $record = mysql_fetch_array ( $result ) )
{
echo $record["name"] . "
" . $record[1];
}
comment: ถ้า type = MYSQL_ASSOC คือ key ต้องเป็นชื่อคอลัมน์เท่านั้น
ถ้า
type
= MYSQL_NUM คือ key ต้องเป็นคอลัมน์ที่เท่านั้น
ถ้า
type
= MYSQL_BOTH คือ key เป็นได้ทั้งชื่อคอลัมน์และคอลัมน์ที่
( default )
ไม่มีความคิดเห็น:
แสดงความคิดเห็น