I need a little help, I'm using the mvc standard with codeigniter and I need to echo the view, searching for values from the same column from the same table. So in my view I have two input text where I would call the users name by ID, the fact that I can call one but I can not call the other, as the reference would be "name" which is the name of the column, just repeating the text of the first input, because I can not find a term that differentiates the call. Remembling that in this table "OS" has a foreign key to the table "users" and there is the auto complete function. This I am trying to do is a branch break;)
model
public function autoCompleteUsuario($q){
$this->db->select('*');
$this->db->limit(5);
$this->db->like('nome', $q);
$this->db->where('situacao',1);
$query = $this->db->get('usuarios');
if($query->num_rows() > 0){
foreach ($query->result_array() as $row){
$row_set[] = array('label'=>$row['nome'].' | Telefone: '.$row['telefone'],'id'=>$row['idUsuarios']);
}
echo json_encode($row_set);
}
}
controller
public function autoCompleteUsuario(){
if (isset($_GET['term'])){
$q = strtolower($_GET['term']);
$this->os_model->autoCompleteUsuario($q);
}
view
<input id="usuario" class="span12" type="text" name="usuario" value="<?php echo $result->nome ?>" />
<input id="usuario2" class="span12" type="text" name="usuario2" value="<?php echo $result->nome ?>" />