[eluser]srpurdy[/eluser]
You would just do a foreach loop for the second query. that would loop through all the results.
This just depends on how your passing the information to the query so you know which prices to get. Best way is to use a uri segment.
So for example if your uri segment is Mustang-5-0
You could do a query like this (just change segment 3 to whatever it is.
url_model_name should be a url friendly field with dashes -
Code:
function get_car_prices()
{
$car_prices = $this->db
->where('models.url_model_name', $this->uri->segment(3))
->where('models.model_id = model_prices.model_id')
->select('
model_prices.dealership_name,
model_prices.price
')
->from('models,model_prices')
->order_by('model_prices.price', 'asc')
->get();
return $car_prices;
}
This is a bit easier if your using id numbers. Cause than all you need is a query like this
Code:
function get_car_prices()
{
$car_prices = $this->db
->where('model_prices.model_id',$this->uri->segment(3))
->select('
model_prices.dealership_name,
model_prices.price
')
->from('model_prices')
->order_by('model_prices.price', 'asc')
->get();
return $car_prices;
}
Controller would have something like
Code:
$data['car_prices'] = $this->cars_model->get_car_prices();
Than in your view you would just foreach loop.
Code:
<?php foreach($car_prices->result() as $cp):?>
html.... <?php echo $cp->price;?>
<?php endforeach;?>