• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 195

Backtrace:

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/views/question.php
Line: 195
Function: _error_handler

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/controllers/Questions.php
Line: 416
Function: view

File: /home/u125378470/domains/lawhelpguru.org/public_html/index.php
Line: 315
Function: require_once

I am creating a table with content fed from a table in a MySQL Database. One of the fields on the table is a checkbox form that adds roles to the user. I got it to work, but with the description being hardcoded. Since a new role might get added, I want to show it as a new checkbox option.

Clarification: the value of 1 sets the role as Admin, 2 as Subscriber...

The problem is the message: Notice: Array to string conversion in /var/www/html/wordpress/multi_users/user_table.php on line 110

<?php
$records_roles = mysqli_query($connect, "SELECT role_name FROM tbl_roles");
$roles = array();
$count = 0;
while ($course_roles = mysqli_fetch_assoc($records_roles)){
    $roles []= $course_roles;
    $count++;
} 
?>

<!DOCTYPE html>
<html lang="en">
<html>
<head>
    <title>Modify users</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="jquery-tabledit-1.2.3/jquery.tabledit.min.js"></script>
</head>

<body>
<div class="container">
    <br />
    <br />
    <br />
    <div class="table-responsive">
        <h3 align="center">Modifying Users</h3><br />
        <table id="editable_table" class="table table-bordered table-striped">
            <thead>
            <tr>
                <th>ID</th>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Email</th>
                <th>Approval</th>
                <th>Roles</th>
            </tr>
            </thead>
            <tbody>
            <?php
            while($row = mysqli_fetch_array($result))
            {
                echo '
              
               '.$row["user_id"].'
               '.$row["first_name"].'
               '.$row["last_name"].'
               '.$row["email"].'
               
                    <form method="post">
                        <input type="hidden" name="user_id" value='"user_id"].'>

                        <select name="admin_approved">
                            
                            
                            
                        </select>
                        <button type="submit" name="selectSubmit" >Submit</button>
                    </form>
               
               
               
                    <form method="post">
                        Select user roles
<input type="hidden" name="user_id" value='
"user_id"].'> '; for ($a = 1; $a <= $count ; $a++){ echo '<input type="checkbox" name="techno[]" value="$a" />' .$roles[($a-1)]. "
"
; }// line 110 echo ' </form> '; } ?> </tbody> </table> </div> </div> </body> </html>