Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP/DAO/MYSQL的年份范围_Php_Mysql - Fatal编程技术网

PHP/DAO/MYSQL的年份范围

PHP/DAO/MYSQL的年份范围,php,mysql,Php,Mysql,好了 我有功能 public function getCarAttr() { $this->dao->select(); $this->dao->from( $this->getTable_CarAttr()); //$this->dao->where('fk_i_item_id', $itemId); $this->dao->groupBy('i_year', 'ASC') ;

好了 我有功能

public function getCarAttr()
    {
        $this->dao->select();
        $this->dao->from( $this->getTable_CarAttr());
      //$this->dao->where('fk_i_item_id', $itemId);
      $this->dao->groupBy('i_year', 'ASC') ;

        $result = $this->dao->get();
        if( !$result ) {
            return array() ;
        }

        return $result->result();
    }
来自以下领域:

<div class="row one_input">
    <h6><?php _e('Year', 'cars_attributes'); ?></h6>
    <select name="year" id="year">
        <option value=""><?php _e('From', 'cars_attributes'); ?></option>
        <?php foreach($years as $y) { ?>
            <option value="<?php echo $y['fk_i_item_id']; ?>" <?php if($year==$y['fk_i_item_id']) { echo 'selected'; } ?>><?php echo $y['i_year']; ?></option>
        <?php } ?>
    </select>
    <select name="year" id="year">
        <option value=""><?php _e('To', 'cars_attributes'); ?></option>
        <?php foreach($years as $y) { ?>
            <option value="<?php echo $y['fk_i_item_id']; ?>" <?php if($year==$y['fk_i_item_id']) { echo 'selected'; } ?>><?php echo $y['i_year']; ?></option>
        <?php } ?>
    </select>
</div>
现在它向我展示了汽车生产年份没有问题, 他们从最低到最高排序没问题

但我的问题是当我选择2001年和2003年
单击“优化”按钮后,将显示2003和2003,系统显示“无匹配结果”任何想法???

您选择的标签具有相同的ID和名称。HTML元素必须具有唯一的ID。名称可以重复,但由于您使用它们按范围筛选年份,请将它们更改为其他名称,如fromYear和toYear,或其他任何名称。我更改为f_year和t_year,现在在优化后,它会显示所有结果,并将其自身重置为“FROM”&“to”哪一个被定义为占位符?我只是想知道如何设置函数范围,或者更可能是介于两者之间应该可以吗?任何人都可以帮助??您选择的标签具有相同的ID和名称。HTML元素必须具有唯一的ID。名称可以重复,但由于您使用它们按范围筛选年份,请将它们更改为其他名称,如fromYear和toYear,或其他任何名称。我更改为f_year和t_year,现在在优化后,它会显示所有结果,并将其自身重置为“FROM”&“to”它被定义为占位符,我只是想知道如何设置函数范围,或者更可能是介于两者之间应该可以吗?任何人都可以帮助??
    // self-explanatory
function cars_item_detail() {
    if( osc_is_this_category('cars_plugin', osc_item_category_id()) ) {
        $detail   = ModelCars::newInstance()->getCarAttr(osc_item_id()) ;

        if( count($detail) == 0 ) {
            return ;
        }

        $make     = ModelCars::newInstance()->getCarMakeById( $detail['fk_i_make_id'] );
        $model    = ModelCars::newInstance()->getCarModelById( $detail['fk_i_model_id'] );
        $car_type = ModelCars::newInstance()->getVehicleTypeById($detail['fk_vehicle_type_id']);
        $year = ModelCars::newInstance()->getCarAttr($detail['i_year']);

        $detail['s_make'] = '' ;
        if( array_key_exists('s_name', $make) ) {
            $detail['s_make']  = $make['s_name'];
        }
        $detail['s_model'] = '' ;
        if( array_key_exists('s_name', $model) ) {
            $detail['s_model']  = $model['s_name'];
        }
        $detail['locale']  = array() ;
        foreach($car_type as $c) {
            $detail['locale'][$c['fk_c_locale_code']]['s_car_type'] = $c['s_name'] ;
        }
        $detail['i_year'] = '' ;
        if( array_key_exists('i_year', $model) ) {
            $detail['i_year']  = $model['i_year'];
        }
        require_once 'item_detail.php' ;
    }
}

    // Adds some plugin-specific search conditions
function cars_search_conditions($params) {
    // we need conditions and search tables (only if we're using our custom tables)
    $has_conditions = false ;
    foreach($params as $key => $value) {
        // we may want to have param-specific searches
        switch($key) {
            case 'type':
                if( is_numeric($value) ) {
                    Search::newInstance()->addConditions(sprintf("%st_item_car_attr.fk_vehicle_type_id = %d", DB_TABLE_PREFIX, $value));
                    $has_conditions = true;
                }
            break;
            case 'make':
                if( is_numeric($value) ) {
                    Search::newInstance()->addConditions(sprintf("%st_item_car_attr.fk_i_make_id = %d", DB_TABLE_PREFIX, $value));
                    $has_conditions = true;
                }
            break;
            case 'model':
                if( is_numeric($value) ) {
                    Search::newInstance()->addConditions(sprintf("%st_item_car_attr.fk_i_model_id = %d", DB_TABLE_PREFIX, $value));
                    $has_conditions = true;
                }
            break;
            case 'year':
                if( is_numeric($value) ) {
                    Search::newInstance()->addConditions(sprintf("%st_item_car_attr.i_year = %d", DB_TABLE_PREFIX, $value));
                    $has_conditions = true;
                }
            break;
            case 'transmission':
                if( $value == 'AUTO' || $value == 'MANUAL' ) {
                    Search::newInstance()->addConditions(sprintf("%st_item_car_attr.e_transmission = '%s'", DB_TABLE_PREFIX, $value));
                    $has_conditions = true;
                }
            break;
            default:
            break;
        }
    }