วันอังคารที่ 9 ธันวาคม พ.ศ. 2557

mysql_fetch_assoc()

Mysql Function: mysql_fetch_assoc()
function:  mysql_fetch_assoc ( result );
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_assoc ( $result ) )
{
     echo $record["name"] . " " . $record["position_name"];

}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น