Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Controller</p> <pre><code>public function category($category_id){ $data=array(); $data['result'] = $this-&gt;home_model-&gt;selectProductByCategoryId($category_id); // Added this line $data['category'] = $this-&gt;home_model-&gt;selectCategoryByd($category_id); $data['maincontent'] = $this-&gt;load-&gt;view('category_detail',$data,TRUE); $this-&gt;load-&gt;view('home', $data); } </code></pre> <p>Model_Home</p> <pre><code>public function selectCategoryById($category_id) { $result = $this-&gt;db-&gt;select('*') -&gt;from('tbl_category') -&gt;where('id',$category_id) -&gt;get() -&gt;result(); return $result; } </code></pre> <p>Then echo some of those in your view.</p> <p>You are using a <code>Model_Home</code> for other models functions?<br> Models are for data and everything what has to do with that data. You should have a <code>Model_Category</code> with a <code>selectById</code> function and a <code>Model_Product</code> with a <code>selectByCategoryId</code> AND a <code>selectById</code> function. Models are NOT used to describe pages.</p> <p>Please read about <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="nofollow">MVC</a> and <a href="http://ellislab.com/codeigniter/user-guide/overview/mvc.html" rel="nofollow">CodeIgniters implementation of it</a>. Then refactor your code and properly use codeigniters features which, if implemented correctly, allow you to not even have to write these functions yourself! Note: I do not know CI very well, so I don't know about the specific implementations of e.g. MVC, ORM, and the like</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload