![]() |
Sorting not working for dynamic values. - 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: Sorting not working for dynamic values. (/showthread.php?tid=63302) |
Sorting not working for dynamic values. - prasad - 10-16-2015 Hello everybody, I'll get right to it. I am trying to a sort user list by either desc or asc. My controller looks like this - PHP Code: public function ByUser($sort_by = 'issue_date', $sort_order = 'desc') In my model, i have an inner join that joins two tables and shows issues by specific user. My model method looks like this - PHP Code: public function issues_by_user($sort_by, $sort_order, $user_type) Query works fine. (Checked it using print_r) But when i change the url to - "http://localhost/anothertrack/report/ByUser/id/asc", all the records that were fetched go away. If i print_r, all i see is an empty array. However, if i remove the variable PHP Code: $user_type PHP Code: ->where('role', $user_type) Where am i going wrong here? RE: Sorting not working for dynamic values. - ignitedcms - 10-17-2015 This suggests your post for usertype is not being fetched correctly. Can you show you html for the drop down? RE: Sorting not working for dynamic values. - lazyfox - 10-18-2015 Try to figure it out by displaying the $user_type's value before query. if it is null value then something wrong there. That's why you get an error in your code/query. I suggest you to initialize your variable $user_type to 1 or any default value from your database ($user_type = 1). Hope it will help ![]() God bless and more power! RE: Sorting not working for dynamic values. - Avenirer - 10-19-2015 If you change the url then you have no more POST data... only GET data. |