[eluser]harris_priambudi[/eluser]
[quote author="Tominator" date="1338990430"]You can do that using Active Record:
Code:
$this->db->from('car_data');
if ( ! empty( $car_name ))
$this->db->where('car_name', $car_name);
if ( ! empty( $car_colour ))
$this->db->where('car_colour', $car_colour);
if ( ! empty( $car_horsepower ))
$this->db->where('car_horsepower', $car_horsepower);
$query = $this->db->get();
Or you can try to code your own, like that:
Code:
if ( ! empty( $car_name ))
$array[] = ('car_name = '. $car_name);
if ( ! empty( $car_colour ))
$array[] = ('car_colour = '. $car_colour);
if ( ! empty( $car_horsepower ))
$array[] = ('car_horsepower = '. $car_horsepower);
$where = implode(' or ', $array);
$query = "SELECT * FROM car_data WHERE ". $where;
I hope this helps
I'm thinking about other solutions ...[/quote]
Wow thx for the answer, I understand the logic for this problem
but I confuse about this code
its error when im compile..