Hi I am new to open cart. I need to create a simple search module
I have a table with following content and i need to perform search in the following table
store id adress NAME
1 1,xyzs ABC
2 2,cbvg SDDD
3 7,vksh FDSDF
4 8,dghdh SDFSD
Please suggest me how to proceed.
you will need to know how to write SQL statements. from there, link it up to the front end html codes to display the search box.
your request is pretty vague, so nothing much we can help you with here.
your request is pretty vague, so nothing much we can help you with here.
Thanks for your reply i just tried but need some assistance so pls if you could help its much appreciated
This is model
here is controller
here is the view
i don know is this correct approach please help me
This is model
Code: Select all
$query = $this->db->query("SELECT * FROM " . DB_PREFIX. 'store WHERE name like "%'.$this->request->get['search'].'%" OR address like "%'.$this->request->get['search'].'%");
$store_data = $query->rows;
return $store_data;
here is controller
Code: Select all
if (isset($this->request->get['search'])) {
$search = $this->request->get['search'];
} else {
$search = '';
}
if (isset($this->request->get['search'])) {}
if (isset($this->request->get['search']) ) {
$data['stores'] = array(
'name' => $search,
);
$this->load->model('setting/store');
$results = $this->model_setting_store->getstore();
foreach ($results as $result) {
$data['stores'][] = array(
'store_id' => $result['store_id'],
'name' => $result['name'],
'address' => $result['address'],
);
}
}
$data['search'] = $search;
here is the view
Code: Select all
<input type="text" name="search" value="<?php echo $search; ?>" placeholder="<?php echo $text_keyword; ?>" id="input-search" class="form-control" />
<input type="button" value="<?php echo $button_search; ?>" id="button-search" class="btn btn-primary" />
<?php foreach ($stores as $store) { ?>
<?php if ($store['store_id'] == $store_id) { ?>
<a href="<?php echo $store['url']; ?>"><b><?php echo $store['name']; ?></b></a>
<?php echo $store['address']; ?>
<br />
<?php } else { ?>
<p><?php echo '"No result"; ?></p>
<br />
<?php } ?>
<?php } ?>
i don know is this correct approach please help me
Who is online
Users browsing this forum: No registered users and 2 guests