Sorting not working for dynamic values. |
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?
This suggests your post for usertype is not being fetched correctly.
Can you show you html for the drop down?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
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!
If you change the url then you have no more POST data... only GET data.
Website: http://avenir.ro
|
Welcome Guest, Not a member yet? Register Sign In |