Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
cuadro de búsqueda en codeigniter dando datos en blanco

tengo un cuadro de búsqueda simple en codeigniter, el controlador es el siguiente:

 function searchtrack() { $this->load->model('excel_import_model'); if(isset($_POST['submittrack'])) { $awb=$this->input->post('awb'); $data['slt']= $this->excel_import_model->searchtrack($awb); $this->load->view("searchtrack",$data); } } }

el modelo es como a continuación:

 public function searchtrack($awbno) { $this->db->select('*'); $this->db->where("awb", $awbno); $this->db->from('consignments'); $query = $this->db->get(); $result = $query->result(); return $result; }

y finalmente la vista de pantalla:

 <?php foreach($slt as $val){ echo $val->id; } ?>

sin embargo, esto no me da ningún valor, la entrada de la publicación se pasa al controlador y a la columna de la base de datos y todo está bien, ¿alguien puede decirme qué está mal aquí? Gracias de antemano.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

En su modelo, reemplace "dónde" con "me gusta ". "Dónde" busca datos específicos donde "me gusta" busca datos similares.

 public function searchtrack($awbno) { $this->db->select('*'); $this->db->like("awb", $awbno, 'both'); $this->db->from('consignments'); $query = $this->db->get(); $result = $query->result(); return $result; }

Para controlar dónde se coloca el comodín (%) en el método "me gusta", se utiliza un tercer parámetro.

 $this->db->like('awb', $awbno, 'before'); // Produces: WHERE `title` LIKE '%match' ESCAPE '!' $this->db->like('awb', $awbno, 'after'); // Produces: WHERE `title` LIKE 'match%' ESCAPE '!' $this->db->like('awb', $awbno, 'none'); // Produces: WHERE `title` LIKE 'match' ESCAPE '!' $this->db->like('awb', $awbno, 'both'); // Produces: WHERE `title` LIKE '%match%' ESCAPE '!'
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!