0

I am currently creating a project in which a user will be allowed only to download certain columns in a mysql table.

The first part of my question is how do i make it so I can download certain columns into the form of an CSV.

The second part is how do I allow only users to download the columns that they have permission for.

For example I am person A and i want to download the data from this table. I am only allowed to download columns 1, 4 , and 7. This data will come to me in the form of a CSV that I can view and modify in excel.

I dont want the users to be able to view the data they dont have access to.

  • Give the users permission sets and check it in your code. Once correct run a select, fetch it, and serve the content. Send the `CSV` header. http://stackoverflow.com/questions/17269568/force-download-csv-file – chris85 May 14 '17 at 02:42
  • this has nothing to do with phpmyadmin (which is just another php script not a data base) –  May 14 '17 at 02:52

1 Answers1

1

You will need to create a small web application for that . This will require time, sorry, no easy way :

  1. Create some form of authentication system (login form or access code) for the users, getting the data from your users table. You probably already have that.

  2. In phpMyAdmin add a column named PERMISSIONS in your users table and in that column put the columns the user will have access to (you can separate it by commas just like in your example).

  3. When the user logs in fetch the user permissions stored for it and make it explode ( http://php.net/manual/es/function.explode.php ) . This will allow you to create a menu consisting only of the columns you allowed to the user.

  4. Then make a form. Inside this form you will need to add a select menu (https://www.w3schools.com/tags/tag_select.asp) generated with a while loop using result of the explode function and a submit button.

  5. Upon clicking on the submit button the user will be directed to a script . Get the column selected in the select menu by the user using the POST method .

  6. The run the SQL statement: ' SELECT $column_X FROM table_X ' and then fetch it using again a while loop to format the result ( Convert array into csv ) .

  7. Finally give the result in a CSV file .

Community
  • 1
  • 1