我想知道是否有可能从一列中选择多个结果,其他列:如何选择更多匹配其他列的列的结果?
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