We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

how to two table search using codegniter 1st table articles and 2nd table is enter and colum same title plz help

Development and Programming

sallo's avatar
sallo
1 posts
9 years ago
sallo's avatar sallo

my model search <?php

class Movies extends CI_Model {

public function lists( ) { $query =$this->db ->select(‘title’)

->from(‘articles’)

->get(); return $query->result();

}

public function search_rows( $query ) {

$q = $this->db->from(‘enter’) ->like(‘title’, $query ) ->get(); return $q->result();

}

my controller search <?php

class Haris extends MY_Controller {

public function index() { $this->load->helper(‘form’); $this->load->model(‘movies’); $articles = $this->movies->lists(); $this->load->view(‘public/articles_list’,[‘articles’=>$articles]);

}

public function search_row() { $this->load->library(‘form_validation’); $this->form_validation->set_rules(‘query’,’Query’,’required’);

if( ! $this->form_validation->run())

$this->index();

$query = $this->input->post(‘query’);

$this->load->model(‘movies’);

$articles = $this->movies->search_rows($query);

$this->load->view(‘public/search_result’,compact(‘articles’));

}

}view page <?= form_open(‘user/search’,[‘class’=>’navbar-form navbar-left’,’role’=>’serach’]) ?>

<div class="form-group">
      <input type="text" name="query" class="form-control" placeholder="Search">
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
 <?= form_close();?> 
  <?= form_error('query',"",'')  ?>

!———-!

my 2nd model search <?php

class Movies extends CI_Model {

public function lists( ) { $query =$this->db ->select(‘title’)

->from(‘enter’)

->get(); return $query->result();

}

public function search_rows( $query ) {

$q = $this->db->from(‘enter’) ->like(‘title’, $query ) ->get(); return $q->result();

}

my 2nd controller search <?php

class Haris extends MY_Controller {

public function index() { $this->load->helper(‘form’); $this->load->model(‘movies’); $articles = $this->movies->lists(); $this->load->view(‘public/view’,[‘articles’=>$articles]);

}

public function search_row() { $this->load->library(‘form_validation’); $this->form_validation->set_rules(‘query’,’Query’,’required’);

if( ! $this->form_validation->run())

$this->index();

$query = $this->input->post(‘query’);

$this->load->model(‘movies’);

$articles = $this->movies->search_rows($query);

$this->load->view(‘public/search_result’,compact(‘articles’));

}

}

but i dont now alreadyt define searc in form_open plz help what i do

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.