What I am trying to do is, have a different coupon for each record based upon the year make model and mileage of a vehicle. I am doing this in the middle of a query, that selects the vehciles. It seems what happens is that when it finds a match it doesn't stop, it keeps going and defaults to the last one. Here is the code.
/////Smart Coupons
$query171 = "SELECT * FROM coupons WHERE dealer = 'DEALER' and template = 'main' and position = '1'";
$result171 = mysql_query($query171);
while ($row171 = mysql_fetch_array($result171)) {
$coupon1id = $row171["id"];
$coupon1type = $row171["type"];
$coupon1year = $row171["year"];
$coupon1make = $row171["make"];
$coupon1model = $row171["model"];
$coupon1mileage_low = $row171["mileage_low"];
$coupon1mileage_high = $row171["mileage_high"];
for($i = 0; $i < count($ro); $i++){
if($coupon1type == 'smart'){
if(($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 = 'DEALER' and template = 'main' and position = '1' and type = 'default'";
$result17 = mysql_query($query17);
while ($row17 = mysql_fetch_array($result17)) {
$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>";
Let me know what you think. Any idea's.