這裏是我的解決方案,從表中只顯示兩個值的所有... ...
include('connect-db.php');
$result = mysql_query("SELECT * FROM patientvaccinedetail") //getting all the fields
while($row = mysql_fetch_assoc($result)) {
$data = array('name' => $row['name'] , 'gender' => $row['gender']); //get the two values into one array
print_r(json_encode($data)); //printing the name and gender
}
如果你想在這裏得到的只有兩個領域是另一個查詢...
include('connect-db.php');
$result = mysql_query("SELECT name,gender FROM patientvaccinedetail") //getting two the fields
while($row = mysql_fetch_assoc($result)) {
print_r(json_encode($row)); //printing the name and gender
}
您正在使用mysql_ *功能現在被棄用,並將從PHP在future.So你被移除需要開始使用MySQLi或PDO。 – Nawin