![]() |
categories display problem show all categories - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: categories display problem show all categories (/showthread.php?tid=764) |
categories display problem show all categories - asifagaria - 01-14-2015 Controller Code: public function category() { Code: public function get_categories($order_by = null, $sort = 'DESC', $limit = null, $offset = 0) { Code: <?php foreach ($articles as $article) : ?> please solve this problem display all categories not for selected category RE: categories display problem show all categories - Avenirer - 01-15-2015 Hello to you too... RE: categories display problem show all categories - asifagaria - 01-15-2015 Any Solution Please RE: categories display problem show all categories - mwhitney - 01-15-2015 It would probably help if you explained: - What you expected to happen - What is actually happening To me, it looks like you are getting a list of articles, including the category of each article. If you want a list of possible categories, you need to select the categories from the database. If you just want a list of categories used by the articles in the list, you should be able to create that list from the data you already have. RE: categories display problem show all categories - bclinton - 01-15-2015 (01-15-2015, 01:18 PM)mwhitney Wrote: It would probably help if you explained: Yeah, it really helps if you do more debugging yourself and refine your issue into a more simple question. What data is your query returning? Is it the data you expect it to return? Is your query working as intended but the view is not rendering as you expect? It seems as if you are asking a very generic "how do I do this" question that is not specific to CodeIgniter and that language difficulties make it hard to understand exactly what that question is. RE: categories display problem show all categories - asifagaria - 01-16-2015 i say how i get posts on categories like a ----->arcade games categories -> ----->pc games i want get only pc games it's show all on categories like pc games and arcade game it's show on display posts so how solve this i dont understand this RE: categories display problem show all categories - Rufnex - 01-16-2015 You have to add a where clause to your model like PHP Code: public function get_categories($category_name = false, $order_by = null, $sort = 'DESC', $limit = null, $offset = 0) { Or you check the where with the category id .. RE: categories display problem show all categories - asifagaria - 01-16-2015 (01-16-2015, 03:40 AM)Rufnex Wrote: You have to add a where clause to your model like This Give Error Code: A Database Error Occurred RE: categories display problem show all categories - Rufnex - 01-16-2015 My code was a pseudo code .. i dont know what table fields you have. You have to ajust this with you needs for e.g. with a proper catogry id like PHP Code: public function get_categories($category_id = false, $order_by = null, $sort = 'DESC', $limit = null, $offset = 0) { This means, that your categories table as a column name id or in the example before a column named name. RE: categories display problem show all categories - asifagaria - 01-16-2015 This Time Error Change my table fields is categories table and ( id pkey ) ( name var ) and articles table ( id pkey ) ( title var ) ( category_id int ) Code: A PHP Error was encountered PHP Code: A Database Error Occurred This Time Error Change Please Solve My Problem my table fields is categories table and ( id pkey ) ( name var ) and articles table ( id pkey ) ( title var ) ( category_id int ) |