Is there away I can order table data ? |
My table looks like this , and I'm trying to allow user to change data order asc/desc by clicking the button at thead. I'm not sure how to do it , any idea ?
@cyjuice,
I'm unable to see the image. There are multiple things you can do to achieve your objective (Datatables [ https://datatables.net/ ] is one suggestion). Hopefully you can add a picture so that we can see what we are working with.
Without any code from your part, it's just guessing how you initialize the table, but let's assume you've read the CI documentation.
Your controller function could look like this (controller named "Orders.php"): PHP Code: public function table($order = 'asc') Your model (Orders_model.php): PHP Code: public function get_all($order) Your view (orders_table.php): PHP Code: <table> In this example, you won't see a button, but just a link to change the current order from 'asc' to 'desc'. Hopefully this will give you the idea how it works. Later on, you can change the link into a button. Good luck! |
Welcome Guest, Not a member yet? Register Sign In |