可能不是一個標題的最佳描述,但我真的想不出任何東西。 我想要發生的是,我可以創建一個查詢,從列表中使用userID作爲關係選擇類型,然後選擇城鎮。使用變量選擇列
TABLE listings
saleID userID type description
1 23 clothing nice clothing
2 45 clothing More nice Clothing
TABLE users
userID country county town
23 uk county townname1
24 uk county townname2
的變量在URL中設置爲獲取EG)?=型服裝&鎮= townname2
if (!isset($type)){
$query = "SELECT * FROM listings";
}
if (isset($type)) {
$query = "SELECT * FROM listings WHERE type = '{$type}'";
}
這是位卻困我想與所有房源變量$型「服裝」,然後從用戶變量$鎮
if (isset($town)) {
$query = "SELECT users.town listings.userID listings.type FROM listings
WHERE type = '{$type}'
INNER JOIN users
ON users.town = '{$town}'";
}
霍普鎮我已經解釋了這口井enou選擇呃理解。 請幫我這最後詢問
還驗證輸入值SQL注入,看看http://en.wikipedia.org/wiki/SQL_injection –