for some reason this always defaults to the last one. Is there a way I can get it to stop if it finds a match.
/////Smart Coupons
$query171 = "SELECT * FROM coupons WHERE dealer = 'FRIENDLYRECOMMEND' and template = 'main' and position = '1'";
$result171 = mysql_query($query171);
while ($row171 = mysql_fetch_array($result171,MYSQL_ASSOC)) {
$coupon1id = $row171["id"];
$coupon1option = $row171["option"];
$coupon1year_low = $row171["year_low"];
$coupon1year_high = $row171["year_high"];
$coupon1make = $row171["make"];
$coupon1model = $row171["model"];
$coupon1mileage_low = $row171["mileage_low"];
$coupon1mileage_high = $row171["mileage_high"];
if($coupon1option == '1'){
if($YEAR >= $coupon1year_low && $YEAR <= $coupon1year_high){
$coupon1text1 = $row171["text_1"];
$coupon1text2 = $row171["text_2"];
$coupon1text3 = $row171["text_3"];
$coupon1text4 = $row171["text_4"];
}
}
elseif($coupon1option == '2'){
if($nextincrementmileage >= $coupon1mileage_low && $nextincrementmileage <= $coupon1mileage_high){
$coupon1text1 = $row171["text_1"];
$coupon1text2 = $row171["text_2"];
$coupon1text3 = $row171["text_3"];
$coupon1text4 = $row171["text_4"];
}
}
elseif($coupon1option == '3'){
if($MAKE == $coupon1make && $MODEL == $coupon1model){
$coupon1text1 = $row171["text_1"];
$coupon1text2 = $row171["text_2"];
$coupon1text3 = $row171["text_3"];
$coupon1text4 = $row171["text_4"];
}
}
elseif($coupon1option == '4'){
if($YEAR >= $coupon1year_low && $YEAR <= $coupon1year_high && $MAKE == $coupon1make && $MODEL == $coupon1model && $nextincrementmileage >= $coupon1mileage_low && $nextincrementmileage <= $coupon1mileage_high){
$coupon1text1 = $row171["text_1"];
$coupon1text2 = $row171["text_2"];
$coupon1text3= $row171["text_3"];
$coupon1text4 = $row171["text_4"];
}
}else{
$query17 = "SELECT * FROM coupons WHERE dealer = 'FRIENDLYRECOMMEND' and template = 'main' and position = '1' and type = 'default'";
$result17 = mysql_query($query17);
while ($row17 = mysql_fetch_array($result17,MYSQL_ASSOC)) {
$coupon1text1 = $row17["text_1"];
$coupon1text2 = $row17["text_2"];
$coupon1text3 = $row17["text_3"];
$coupon1text4 = $row17["text_4"];
}
}
}
print "<td>$coupon1text1</td>
<td>$coupon1text2</td>
<td>$coupon1text3</td>
<td>$coupon1text4</td>";