filter data by URI (newbie question) |
[eluser]Rick Blackdog[/eluser]
Hi, just getting to grips with CI, love it so far. I've been able to do CRUD stuff with my data but something I haven't been able to do is displaying the data on a page from a specific record as per the URI. What's the best way of doing this? Thanks for the help Rick
[eluser]cahva[/eluser]
The easiest way is to use the records id. For example if you have a blog and want to show blog post depending on the id, you would have link something like this: http://yourblog.com/blog/view_post/2 That means that you have a controller called a blog with method "view_post". 2 would be the parameter to view_post. The controller would be something like this: Code: class Blog extends Controller { Model blog_model would have that get_post($id) method where you grab the post depending on the $id and pass finally pass it to the view with $data. |
Welcome Guest, Not a member yet? Register Sign In |