Welcome Guest, Not a member yet? Register   Sign In
Sorting by categories - best practice
#1

[eluser]Unknown[/eluser]
I am building a site which has 13 different categories. When a user clicks one of the categories I'm going to display the records that belong to that category. What's the best way to do this with Codeigniter?

I am retreiving the categories from the database and putting them into a list:

Code:
<ul>
        <li>Categories</li>
        &lt;?php foreach($categories as $category) : ?&gt;
        <li><a href="&lt;?php echo $category-&gt;name; ?&gt;">&lt;?php echo $category->name; ?&gt;</a></li>
  &lt;?php endforeach; ?&gt;
</ul>

When a user clicks on one of these categories how should I process that information?

My first thought is to create a new controller for categories and have a separate function for each category. Is that the best way? Or should I use $this->uri->segment?

Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB