我有3種不同類型的查詢來檢索同一頁面中的數據。我將如何結合在一起?以下是查詢:如何將3個mysql查詢結合在一起?
<?php
$sql = "SELECT * FROM general WHERE ((day1sql >= now()))";
if($_GET!=""){
$mydate = mysql_real_escape_string($_GET['datepicker']);
if($mydate!=""){
$sql = "SELECT * FROM general WHERE ((day1 = '$mydate'))";
}
}
if($_GET!=""){
$city1 = mysql_real_escape_string($_GET['cityText']);
if($city1!=""){
$sql = "SELECT * FROM general WHERE (city = $city1))";
}
}
datepicker是一個日曆,用戶可以根據日期獲取數據。並有一個下拉菜單,用戶可以選擇城市名稱。前兩個查詢工作正常。我很困惑如何整合第三個查詢?
正如在[介紹](http://www.php.net/manual/en/intro.mysql.php)中給mysql手冊的'mysql_ *'函數一章所述:*不推薦使用此擴展名用於編寫新的代碼。相反,無論是[mysqli](http://www.php.net/manual/en/book.mysqli.php)還是[PDO_MySQL](http://www.php.net/manual/en/ref.pdo應該使用-mysql.php)擴展名。另請參閱[MySQL API概述](http://www.php.net/manual/en/mysqlinfo.api.choosing.php)以獲得進一步幫助,同時選擇MySQL API。* – eggyal