CodeIgniter Forums
User Selected View Table Fields... How To?? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: User Selected View Table Fields... How To?? (/thread-54132.html)



User Selected View Table Fields... How To?? - El Forum - 08-23-2012

[eluser]dhall[/eluser]
I have a single database table with roughly 20 fields.
I want to give the user the ability to select which fields they view in a table on my site.

Here are my thoughts on how to do this.
Give the user a list of all fields with a checkbox for each.
This is then saved to a different database table.
When the user calls this particular page it first pulls their selected fields, puts the results into a mysql query somehow, then builds the table with the results.

Does this sound correct?
Anyone have a good example of this or some helpful advice?

Thanks!


User Selected View Table Fields... How To?? - El Forum - 08-23-2012

[eluser]Aken[/eluser]
Sounds about right to me. No examples of how to do it, but follow your plan and it should be good.

You might want to obscure the actual column names a bit, just to help prevent people from guessing your DB schema and causing trouble. You'll also want to make sure the actual names that you code into your PHP are never displayed by accident, either from an error or other means.


User Selected View Table Fields... How To?? - El Forum - 08-24-2012

[eluser]dhall[/eluser]
Thanks.
Now how would I go about taking their selected results and putting those into a query to get the matching fields?
MySQL example would help.

Thanks again!


User Selected View Table Fields... How To?? - El Forum - 08-24-2012

[eluser]CroNiX[/eluser]
Assemble the checkbox post values into a comma separated string of field names and have it be the select portion of the query...