ดึงค่าจาก DB มาแสดงค่ะ ตอนออกนอก function ดึงค่า $data ออกมาไม่ได้ค่ะ ขอบคุณล่วงหน้านะค้า
Code (PHP)
function show_user_dt($user_id,&$data){
$strUserQry = "SELECT * FROM `user` WHERE `user_id` = " .$user_id;
$objQuery = mysql_query($strUserQry) or die ("Error Query [".$strUserQry."]");
while($objResult = mysql_fetch_array($objQuery)) {
$data = array ( "0"=>$objResult["user_username"],
"1"=>$objResult["user_password"]);
//$data[0] = $objResult["user_username"];
//$data[1] = $objResult["user_password"];
}
echo "in while-------------username ".$data[0];
echo "in while-------------pw ".$data[1];
return $data;
}
show_user_dt($user_id);
echo "<br> ".$data;
echo " <br>Out of while loop -------------username ".$data["0"];
echo "<br>-------------pw ".$data["1"];
========================================================
Output ค่ะ
========================================================
in while-------------username cus1in while-------------pw cus1
end fn Array
Out of while loop -------------username
-------------pw