Welcome Guest, Not a member yet? Register   Sign In
Searching multiple tables
#1

[eluser]Unknown[/eluser]
The following allows me to search on 'title' and 'quote_text' that are in the quotes table of the database. But I need to add a third field of the author of the quote (quote_author). But in the quotes table, 'quote_author' is represented by a number which means I might have to search on the user table....I don't know how to add that to this code. I did not create this, and am just trying to find my way around codeigniter and php...any suggestions? This code is in the quotes file in the controller folder.



public function search() {

$query = $this->input->post('search_sort') ? $this->input->post('search_sort') : $this->uri->segment(3);


$args = array(
'filters' => array(
array(
'type' => 'like',
'args' => array(
'title' => urldecode($query),
'quote_text' => urldecode($query),

)
),


array(
'type' => 'where',
'args' => array(

'status' => 'approved'

)
)
)
);

$quotes = $this->quote->getQuotes($args);
if ($this->users->is_user_logged_in()) {
$data['user'] = $this->current_user;
} else {
$data['user'] = null;
}

$data['title'] = 'Search Quotes';
$data['url'] = $this->login_url;
$data['quotes'] = $quotes;
$data['categories'] = $this->categories->getCategories();
$data['pagination'] = $this->quote->pagination(count($quotes), 'quotes/search/' . urlencode($query), 4);
$data['offset'] = $this->uri->segment(4) ? $this->uri->segment(4) : 0;
$data['footer'] = $this->load->view('frontend/parts/footer', '', true);
$content['content'] = $this->load->view('frontend/quotes/list', $data, true);
$this->load->view('frontend', $content);
}



}




Theme © iAndrew 2016 - Forum software by © MyBB