url segment - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: url segment (/showthread.php?tid=23679) |
url segment - El Forum - 10-19-2009 [eluser]georgerobbo[/eluser] I'm trying to query my database based on the second segment in my url, however I'm struggling with the controller side. My Model, named Post is as follows. Code: <?php An my controller category Code: <?php url segment - El Forum - 10-19-2009 [eluser]umefarooq[/eluser] hi first keep your model clean only for database functions. get you all url segments in controller and pass to you model functions. controller Code: <?php model Code: function get_posts_by_category($category) also debug it with echo $category in controller that you are getting proper value in you uri segment or not. url segment - El Forum - 10-19-2009 [eluser]georgerobbo[/eluser] The reason It wasn't working is because it was looking for the function instead of the ID. A little bit of URL routing and everything is working. =) |