0
I’m having a problem I can’t seem to solve at all. I have an html form that has a select option to take the selected value when the form is sent and use as parameter for a method, there is some way to do this?
0
I’m having a problem I can’t seem to solve at all. I have an html form that has a select option to take the selected value when the form is sent and use as parameter for a method, there is some way to do this?
2
There is, my friend.
Assuming that the name
of the combobox is consulta
would look like this in the controller:
public funcition Consultar(){
$parametro = $this->input->post('consulta'); //formulário submetido via POST
/*lembrando que o valor que virá submetido pelo formulário
é o que se encontra em value lá no html */
$this->load->model('Nome_da_tua_model');
$res = $this->Nome_da_tua_model->Teu_metodo_de_consulta($parametro);
}
Already in your model
would look like this:
public function Teu_metodo_de_consulta($parametro){
$this->db->Select('*');
$this->db->From('Tua_tabela');
if(!empty($parametro)){
$this->db->where('Tua_tabela.Teu_campo', $parametro);
}
$result = $this->db->get()->Result();
return $result;
}
Now in the controller the variable $res
has the data of your query.
The command SQL
which I executed in the above section, is for equal values, if another type of comparison is required, I advise you to read the documentation in the link.
I hope I helped, Oss!
Thank you! It helped a lot
Browser other questions tagged html codeigniter
You are not signed in. Login or sign up in order to post.
You could put in your code so we can help you?
– Randrade