我想通過選擇treecondition列來顯示treeid,treelatitude和treelongitude。未答覆的PHP - 選擇treecondition列並顯示其他3列
當我POST「健康」,我能夠顯示treeid 4,6 & 7,但如果我POST「平衡」不能得到treeid 1 & 8.我怎樣才能得到它?
在我下面的代碼,我只能能夠顯示「健康」,但無法顯示「平衡」
請給我在我的代碼獲得錯誤
Treeid treelatitude treelongitude treeCondition
1 12.33 17.22 Balanced
2 12.33 17.22 Healthy
3 12.33 17.33 Dieseased
4 13.44 17.55 Healthy
5 11.32 17.66 Imbalanced
6 12.33 18.33 Healthy
7 14.44 18.44 Healthy
8 11.22 17.22 Balanced
<?php
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__.'/public_html/Config.php');
// Connecting to mysql database
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// json response array
$response = array();
$sq = "SELECT treeid, treelatitude, treelongitude FROM tree WHERE (treecondition = 'Healthy','Balanced')";
if (isset($_POST['treecondition'])) {
// receiving the post params
$treecondition = $_POST['treecondition'];
// get the tree details for google map marker
if($stmt = $mysqli->query($sq)){
if ($stmt->num_rows) {
while($tree = $stmt->fetch_assoc()) {
$treeItem = array();
$treeItem["treeid"] = $tree['treeid'];
$treeItem["treelatitude"] = $tree['treelatitude'];
$treeItem["treelongitude"] = $tree['treelongitude'];
$response[] = $treeItem;
} echo json_encode($response);
}
}else {
// user is not found with the credentials
$response["error"] = TRUE;
$response["error_msg"] = "Tree list view credentials are wrong. Please try again!";
echo json_encode($response);
}
$mysqli->close();
}
它不工作!它正在採取所有的樹ID – Bharat
你使用MYSQL? –
當你發佈「平衡」時,你是否仍然「健康」? –