PHP Help

I have a table in my phpMyAdmin, it contains


all the p’s are different permissions,
how would i create a script that can edit the rows of staff and have check boxes when ticked gives them that privileges and un ticked no privileges

Well the concept is very simple. It requires a couple steps. First you need to run a query to get all the people in the db and their unique id. From that list you output their name and link pointing to your update form page with a $_GET var like admin-id=$row[‘id’] ($row[‘id’] being from the first query). Then on the update page you grab the $_GET[‘admin-id’] and put it in a hidden field of the form to submit along with the other fields, you will then use that posted hidden fields value to do a WHERE clause in the update query. Make you form and fields you want, post them and grab their values and validate them as needed. Then run a update query using the hidden fields value in the WHERE clause like WHERE id = $_POST[‘admin-id’] LIMIT 1. I always use LIMIT 1 when testing or in important situations where a single mistake can mean a huge problem for many people. The limit makes it so not matter what the result only one row will be effected in case you have the code wrong.

Beyond that I don’t think anyone will code this for you so you should watch some tutorials on yourtube, there are plenty of them.

On the update script, since you’re using different columns for each permission, you’ll want to give each checkbox a different name. It adds to the line count, but for a beginner, it keeps things simple.

Sponsor our Newsletter | Privacy Policy | Terms of Service