Welcome Guest, Not a member yet? Register   Sign In
database query: how to pass row result from one query to another query
#1

[eluser]vickel[/eluser]
good evening, everyone. maybe somebody can help me with this:

controller:
sends QUERY1 and QUERY2 to the model
loads a view file
view:
has a 1st foreach loop to show QUERY1 results
inside this loop, there is a form with a 2nd foreach loop to show QUERY2 results with radiobuttons.

that works fine, but now the question: How can I pass a certain row result (eg. big_car or small_car) which I get in the 1st foreach loop (QUERY1 results), as variable data to QUERY2 ?

the result in the view should be:

big_car
o extra_1 100€
o extra_2 200€

small_car
o extra_1 300€
o extra_2 600€

the code would be something like:

view:
Code:
<?php foreach($cars as $row):?>
    <?=$row->car_name?>

    <?php foreach($extras as $row):?>
        <?=$row->extra_name?>
    <?php endforeach;?>

<?php endforeach;?>


controller (without the form stuff):
Code:
$this->load->model('data_manager');
$data['cars'] = $this->data_manager->get_cars();
$data['extras'] = $this->data_manager->get_extras();
$this->load->view('carlist', $data);




Theme © iAndrew 2016 - Forum software by © MyBB