0
我有一個表有4個類別列,下面返回第一個category_id。我有3個人稱爲category_id2,category_id3和Category_id4。包含SQL和PHP的多列
$sql_ca = "SELECT * FROM tour_category ORDER BY sort";
$result_ca = mysql_query($sql_ca);
$categories = $Manager->fetchAssoc($result_ca);
if(!empty($categories)){
foreach($categories as $cat){
$sql_tour = "SELECT t.* FROM tour t
WHERE
t.touronline = 'yes'
AND t.category_id = {$cat['id']}
AND t.location_id = {$city['id']}
and t.type = 'P'
ORDER BY t.tourcode
";
$result_tour = mysql_query($sql_tour);
$tours = $Manager->fetchAssoc($result_tour);
我試圖把在
AND t.category_id, t.category_id2, t.category_id3,t.category_id4 = {$cat['id']}
但我只是無法得到這個工作,任何提示?
使用'= {$貓[ 'id']}'爲每列。 – Mihai
嘗試回顯查詢並將其複製並手動檢查 –