A PHP Error was encountered Severity: Notice Message: Undefined index: id
<p>I really need to make this table work but I can't find what's missing in my code or why this variable is undefined. The table works fine. It displays and so is a search box above it. The html code of the table is fine bcos it displays the table. The PHP Errors appear inside the colums of the table where the id, name, etc. are being called. Please I need help..</p>

<p>MY CONTROLLER: (tabledisplay.php)</p>

<pre><code>function index()
    {
        $data = array();
        $this-&gt;load-&gt;model('table_model');
        $data['result'] = $this-&gt;table_model-&gt;display_table();
        $this-&gt;load-&gt;view('table_view', $data);//error here

    }
</code></pre>

<p>MY VIEW: (table_view.php)</p>

<pre><code>&lt;table class="table table-hover"&gt;
              &lt;tr&gt;
                   &lt;th&gt;ID&lt;/th&gt; 
                   &lt;th&gt;First Name&lt;/th&gt;
                   &lt;th&gt;Middle Name&lt;/th&gt;
                   &lt;th&gt;Last Name&lt;/th&gt;
                   &lt;th&gt;Position&lt;/th&gt;
               &lt;/tr&gt;

               &lt;?php
                $row = array();
                foreach ($row as $result); ?&gt;//the values cannot be displayed
               &lt;tr&gt;
                   &lt;td&gt;&lt;strong&gt;&lt;?php echo $row['id']; ?&gt;&lt;/strong&gt;&lt;/td&gt;//error starts here
                   &lt;td&gt;&lt;?php echo $row['fname']; ?&gt;&lt;/td&gt;
                   &lt;td&gt;&lt;?php echo $row['mname']; ?&gt;&lt;/td&gt;
                   &lt;td&gt;&lt;?php echo $row['lname']; ?&gt;&lt;/td&gt;
                   &lt;td width="15%"&gt;&lt;?php echo $row['position']; ?&gt;&lt;/td&gt;
                   &lt;td width="100px"&gt;&lt;button type="submit" class="btn btn-success"&gt;Sign in&lt;/button&gt;&lt;/td&gt;
               &lt;/tr&gt;
              &lt;?php  ?&gt;
</code></pre>

<p>MY MODEL: (table_model.php)</p>

<pre><code>function display_table ()
    {

    function filterTable($query)
    {
        $connect = mysqli_connect("localhost","root","","registerusers");

        $filter_Result = mysqli_query($connect, $query);

        return $filter_Result;

    }

        if(isset($_POST['search']))
        {
              $valueToSearch = $_POST['valueToSearch'];
            // search in all table columns
            // using concat mysql function
            $query = "SELECT * FROM `user`  WHERE CONCAT(`id`, `fname`, `lname`, `position`) LIKE '%".$valueToSearch."%'";
            $search_result = filterTable($query);
        }
        else{
            $query = "SELECT * FROM `user` LIMIT 10";
            $search_result =  filterTable($query);
        }
    return $search_result;
    }
</code></pre>