[eluser]Unknown[/eluser]
I'm using codeigniter to develop a website.
The query result is successfully returned from database, I use a controller to pass the result to a view to display them. and then I want to save the result into files. but I don't how to save the data. I tried to send the data back to a controller, but the variable(the returned result) couldn't be found.
In file query_view.php I set some criteria to let user choose
Code:
<? echo form_open('query/select') ;?>
<select name='name'>
<option value='food' selected="selected">food</option>
</select>
<input type="submit" submit>;
<?php echo form_close(); ?>;
In the controller 'query', I have the 'select' function:
Code:
function select() {
global $data;
$NAME = $this->input->post('name');
$quer = "SELECT * FROM {$TABLENAME} WHERE NAME={$NAME}";
$this->load->model('Mquery');
$data['query'] = $this->Mquery->select($quer);
$this->load->view('query_result', $data);
}
In the "query_result" view, I can display the returned result, but after that I want to save the data, how to do that?
Q1: Should I send the data back to controller? how?
Q2: Should I use javascript to do this on client? How?
Any suggestions would be sincerely appreciated.