Hi

I am struggling how to list all the permissions and with checkboxes.

if anyone can help me with it this is the code

            echo "<table cellpadding='0' cellspacing='0' width='100%' class='table table-bordered'>";
                echo "<tr>";
                    echo "<th>PERMISSION</th>";
                    foreach($user_groups->rows as $row) {
                        echo "<th class='checkbox'>".$row['title']."</th>";
                    }
                echo "</tr>";

                $users_permission_query = $this->db->query("SELECT * FROM users_permission");

                foreach($users_permission_query->rows as $row) {
                    $group_permissions_rows = json_decode($row['permission'], TRUE);
                    echo "<tr>";
                    echo "<td>".$row['module']."<br />";
                        foreach($group_permissions_rows as $key => $value) {
                            echo "{$key}<br>";
                        }
                    echo "</td>";
                    echo "<td>";
                        echo "<table cellpadding='0' cellspacing='0' width='100%'>";
                        for($i=0; $i < count($group_permissions_rows); $i++) {
                            foreach($group_permissions_rows as $key => $value) {
                                echo "<tr>";
                                echo "<td><input type='checkbox' name='permissions[" . $key . "]'";
                                if($value) {
                                    echo ($value==1 ? " checked =\"checked\"" : ""); 
                                }
                                echo " value=$value /></td>";
                                echo "</tr>";
                            }
                        }
                        echo "</table>";
                    echo "</td>";
                    echo "</tr>";
                }

            echo "</table>";

Recommended Answers

All 4 Replies

Ohh..so do I, also need it. I had similar situation last week and still don't understand. I'd like to share with this problem on for further voting. I would be grateful a lots if someone will get right answer.

This is my data,

        $table_permissions = array(
            'users'=>array("create"=>1,"modify_own"=>1,"modify_any"=>1,"delete_own"=>1,"delete_any"=>1,"view"=>1),
            'users_group'=>array("create"=>1,"modify_own"=>1,"modify_any"=>1,"delete_own"=>1,"delete_any"=>1,"view"=>1),
            'news'=>array("create"=>1,"modify_own"=>1,"modify_any"=>1,"delete_own"=>1,"delete_any"=>1,"view"=>1)
        );
        $json_encode = json_encode($table_permissions);
        $json_decode = json_decode('{"users":{"create":1,"modify_own":1,"modify_any":1,"delete_own":1,"delete_any":1,"view":1},"users_group":{"create":1,"modify_own":1,"modify_any":1,"delete_own":1,"delete_any":1,"view":1},"news":{"create":1,"modify_own":1,"modify_any":1,"delete_own":1,"delete_any":1,"view":1}}', true);

how can i make of a form and save to the database

Ohh..so do I, also need it. I had similar situation last week and still don't understand. I'd like to share with this problem on for further voting. I would be grateful a lots if someone will get right answer.

you dont actually state what problem you're having be descriptive no one wants to try to guess

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.