我想知道是否有可能從一列中選擇多個結果,其他列:如何選擇更多匹配其他列的列的結果?
public function SameCars() {
$q = "select * from carads where STATUS='1' and DEL='0' and ADID=".$_REQUEST['carID'];
$result = $this->QueryResult($q);
$myprice = intval($result[0]->PRICE);
$body = $result[0]->BODY;
$pricelow = $myprice - (30/100 * $myprice);
$pricehigh = $myprice + (30/100 * $myprice);
$myyear= $result[0]->YEAR;
$currentyear = date('Y');
$yearlow = $myyear - 5;
if ($yearhigh <= $currentyear-3) {
$yearhigh = $myyear + 5;
} else { $yearhigh = $myyear; }
$samecars = $this->QueryResult("SELECT * FROM carads where BODY LIKE '$body' AND STATUS='1' AND YEAR BETWEEN $yearlow and $yearhigh and DEL='0' and TITLE !='' and TITLE !='-1' and IMAGE1 != '' and IMAGE1 != '-1' and PRICE BETWEEN $pricelow and $pricehigh LIMIT 0,3");
$i=0;
if (count($samecars)) {
foreach ($samecars as $samecar) {$i++;
if($i==3) $cls="news-row last"; else $cls="news-row";
echo '<div class="'.$cls.'">
<div class="img"><a href="'.$base_path.'detail-page_'.$samecar->ADID.'.html">';
if($samecar->IMAGE1!='' && !empty($samecar))
echo '<img src="'.$samecar->IMAGE1.'" alt="" height="79" width="89" />';
else echo '<img src="'.$base_path.'uploads/no-img.jpg" height="79" width="89"/>';
echo '</a></div>
<div class="details">
<h5><a href="'.$base_path.'detail-page_'.$samecar->ADID.'.html">'.$samecar->TITLE.'</a></h5>
<div class="descn">"'.$this->FckContentView($this->closetags(substr($samecar->DESCRIPT, 0,50))).'</div>
</div>
</div>';
}
}
}
我想$make
有比其他標準60%的重要性。
就像這個查詢中的例子,它會迴應一個3匹大拇指的列表,其中前三名來自MAKE
「BMW」,符合這些標準的數據庫。我想輸出3個大拇指;從BMW和1 2個大拇指從另一輛車是標準但不同MAKE
內接近。
總是樣式(縮進)將在這裏之前,你的代碼過載... –
你的意思是你想你'WHERE'子句是'或',而不是'和'? – RedFilter
我試過適合它。像在PHP中縮進? – user3140607