How to use case statement instead of if statement in codeigniter |
I have a code below which seems not to be working so I would want to try case statement instead
Code: <td> I need help to solve the if statement or change it to case statement if it can work pliz. (10-28-2016, 04:17 AM)salain Wrote: You would get more help by specifying what the problem is. I'm trying to show edit and delete buttons if the message->user_id is the same as the user logged in (which means he's the author) and approve button if the logged in user is not the author of the message
Hey,
Still, not saying what the problem is ? What do you expect? and what do you get ? If you always get the the code in the else statement when you are sure the id's are the same then it maybe because one is not set properly print or echo the ids to see if they are set correctly. The way you get the id from the session is depreciated Look here Also you don't need the quote a the end in your anchor PHP Code: echo anchor('admin/messages/edit/'.$message->id, 'Edit', 'class="btn btn-primary"'); I hope this helps A good decision is based on knowledge and not on numbers. - Plato
Using switch:
PHP Code: <td> (10-28-2016, 05:43 AM)Wouter60 Wrote: Using switch:thnks |
Welcome Guest, Not a member yet? Register Sign In |