Advertisement:

Author Topic: Error in mileage search script  (Read 788 times)

ad.min

  • Newbie
  • *
  • Posts: 25
Error in mileage search script
« on: August 28, 2017, 11:24:54 pm »
Hello i have this script for mileage range search :

Quote
<div class="row one_input">
        <h6><?php _e('Mileage', 'cars_attributes'); ?></h6>
      <select name="min_mileage" id="min_mileage">
            <?php $d_min_mileage = Params::getParam('min_mileage') ; ?>
            <option value=""><?php _e('min', 'cars_attributes'); ?></option>
            <?php foreach (range(0, 1000000,25000) as $d_mileage) { ?>
                <option value="<?php echo $d_mileage; ?>" <?php if($d_mileage==$d_min_mileage) { echo 'selected="selected"'; } ?>><?php echo $d_mileage; ?></option>
            <?php } ?>
      </select>   
      <select name="max_mileage" id="max_mileage">
            <?php $d_max_mileage = Params::getParam('max_mileage') ; ?>
            <option value=""><?php _e('max', 'cars_attributes'); ?></option>
            <?php foreach (range(1000000, 0,25000) as $d_mileage) { ?>
                <option value="<?php echo $d_mileage; ?>" <?php if($d_mileage==$d_max_mileage) { echo 'selected="selected"'; } ?>><?php echo $d_mileage; ?></option>
            <?php } ?>
      </select>   
    </div>

When i load the car plugin category, in the sidebar searc in the min and max search boxes instead of 'min' and 'max' implicit values for "" ,when nothing is selected by the visitor, the implicit selected values are equal to '0' so in the min box value instead of 'min' implicit value to be selected appears the  '0' value ; the same with the max box value. This script adds the mileage '0' to '0' search condition without being added by user. I need help to correct the above script so no mileage search condition to be added automatically just by user interaction. If I change the '0' value with '1' value in the foreach loop the script changes the initial values from '0' to 'min' and 'max'  but also increments the value by 1. Many thanks !
« Last Edit: August 29, 2017, 02:55:02 am by ad.min »

ad.min

  • Newbie
  • *
  • Posts: 25
Re: Error in mileage search script
« Reply #1 on: August 29, 2017, 03:04:09 am »
Any better ideas ? Thanks