Hi everyone,

Im pretty new here. Also realy new to PHP and MySql. In my current company they separate the html, php, css, classes codes to different different files. I just want to know, how to create a checkbox list that are create based on datas from database. Basically its about giving access to new users and also editing the access. Lets say:

a.in database we have options like:
-access to delete
-access to add
-access to edit
-access to view.

b.i want all to be listed unchecked for new user and checked for old user (so we can edit the access).

c.i wanted to hav a refresh button to, so all d checkbox will be unchecked once it clicked.(should be easy, ill search for the codes but if you can provide ill be happy.

Thanks in advance.


7 Years
Discussion Span
Last Post by vaultdweller123

I'm curious . If you are new to PHP and SQL, how did they assign you a project like that?
1)You would have to know what the db structure is .
2) there has to to be a permissions table to save the permissions.
3)the admin page would create a table list of users and data permissions with the check boxes via a loop.

These are the basics. You have quite bit of work ahead of you if you are new to PHP and SQl.
Fortunately, the online docs for PHP and MySQl are pretty good.
Good Luck!


S, i am prety new to it but im here for 3 weeks researchin on d system, source code and db.
Actualy im trying to design the user access form with checkboxes. The source code in our company is divided to 3. 1 has all d htmls, 1 has all d php codes, n 1 hav all the classes.
So none of the websites tutorial is helping me because its combining php and html.

I managed to get codes from other system on creating the checkbox and implement it. Thanks.


Hello vry1, I need a tips on somethin.... I have looked on the existing system. Curently in database there is a table called tbl_userinfo which holds info's about our staffs and also wether they are accessible to 3 other systems.

Now the situation eventhough there is 3 column in the table tht suppose to show wether the staff hav access to; let say "access to purchasing system, account system, and payroll". The columns are empty or not realy used. And our company is havin 9 systems rite now to b added.

Now my question is shud i use the existing table to giv access by juz adding 6 more column? Or create a new table which only holds the user id, user name, password and their access to 9 external systems? Im afraid if I use the existing table, d traffic to d table wil b increase but if i create a new table i hav to duplicate all d user id, user name, n password.

What is the plus and minus of both way? and Which way is better?


i dont know if i understand you right... but this is what i understand from your problem... and i come up with this code.

mysql_connect('localhost','root',''); /* i use the default */
mysql_select_db('yourdatabase'); /* your database */
$sql = mysql_query( "SELECT new_user FROM yourtable WHERE userid='1'" ); /* for this sample i have a new_user field to determine new users, '1' is true. Also for the userid is only a sample id, and you should use session instead */
if($row['new_user']==1){ // new user
echo "<input type='checkbox' name='atd' value='atd' /> access to delete<br />
<input type='checkbox' name='ata' value='ata' /> access to add<br />
<input type='checkbox' name='ate' value='ate /> acess to edit<br />
<input type='checkbox' name='atv' value='atv' /> access to view<br />";
echo "<input type='checkbox' name='atd' value='atd' checked='true' /> access to delete<br />
<input type='checkbox' name='ata' value='ata' checked='true' /> access to add<br />
<input type='checkbox' name='ate' value='ate checked='true' /> acess to edit<br />
<input type='checkbox' name='atv' value='atv' checked='true' /> access to view<br />";
<input type='submit' name='btnsubmit' value='submit' />
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.