title: foreach in controller codeigniter
body: <p>I have the following problem, I am working on Codeigniter and I am doing a small validation in the index of my controller this is the code:</p>
  
  <pre><code>function index()
      {
          $user = $this-&gt;session-&gt;userdata("id");
          $data = $this-&gt;customer_model-&gt;get_rol_user($user);
  
          foreach ($data as $row) {
            if ($row-&gt;Url === 'customer/index'){
                 $this-&gt;load-&gt;view('guest/head');
                 $this-&gt;load-&gt;view('guest/nav');
                 $this-&gt;load-&gt;view('guest/section');
                 $this-&gt;load-&gt;view('customer/customer_view');
              }
          }
          redirect(base_url());
  
      }
  </code></pre>
  
  <p>The query works fine, I have already checked, it returns me what I need is the following:</p>
  
  <ul>
  <li><strong>Url</strong></li>
  <li>product/index</li>
  <li>supplier/index</li>
  <li>customer/index</li>
  </ul>
  
  <p>If in the result of my query I have the same value as my condition if, in this case if it is, I would have to load the view otherwise I redirected to the home of my application, I am failing in the foreach?</p>
  
  <p>This is my model:</p>
  
  <pre><code>function get_rol_user($user){
  
      $query = $this-&gt;db-&gt; query("SELECT p.Url
              FROM User AS u INNER JOIN rol AS r ON u.fk_rol = r.id_rol
              INNER JOIN rol_page AS n ON n.fk_rol = r.id_rol
              INNER JOIN page AS p ON n.fk_page = p.id_page
              WHERE u.id_user ='".$user."'");
        if ($query-&gt;num_rows() &gt; 0) {
          return $query-&gt;result();
      }
    } 
  </code></pre>