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

mysql_fetch_object()

Mysql Function: mysql_fetch_object()
function:  mysql_fetch_object ( result );
return type:  array
content:  ใช้คืนค่า ค่าข้อมูล ของ result ในแถวที่ชี้อยู่ และเก็บไว้ที่ object และเลื่อนไปตัวชี้ชี้ไปยังตำแหน่งถ้ดไป
โดย attribute ที่ได้คือชื่อฟิลด์  โดยจะคืนค่า 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_object ( $result ) )
{
     echo $record->name . " " . $record->position_name;

}

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

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