title: Notice Message: Array to string conversion
body: <p>I'm a starter in codeigniter and php, and im facing this problem </p>
  
  <blockquote>
    <p>A PHP Error was encountered</p>
    
    <p>Severity: Notice</p>
    
    <p>Message: Undefined variable: query</p>
    
    <p>Filename: inc/header_main_view.php</p>
    
    <p>Line Number: 175</p>
    
    <p>A PHP Error was encountered</p>
  </blockquote>
  
  <p><strong>VIEW:</strong></p>
  
  <pre><code>&lt;ul class="dropdown-menu"&gt;
  
      &lt;li&gt;
          &lt;!-- inner menu: contains the actual data --&gt;
          &lt;ul class="menu"&gt;
              &lt;?php foreach($query as $row) :?&gt;
                  &lt;li&gt;&lt;!-- Task item --&gt;
                      &lt;a href="#"&gt;
                          &lt;h3&gt;
                              &lt;?php echo $row-&gt;id_task; ?&gt;&lt;?php echo $row-&gt;name; ?&gt;
                              &lt;small class="pull-right"&gt;20%&lt;/small&gt;
                          &lt;/h3&gt;
                          &lt;div class="progress xs"&gt;
                              &lt;div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"&gt;
                                  &lt;span class="sr-only"&gt;20% Complete&lt;/span&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/a&gt;
                  &lt;/li&gt;&lt;!-- end task item --&gt;
              &lt;?php endforeach; ?&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li class="footer"&gt;
          &lt;a href="&lt;?=base_url()?&gt;index.php/dashboard/g_tasks_menu"&gt;View all tasks&lt;/a&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p><strong>CONTROLLER</strong></p>
  
  <pre><code>public function get_todo($id = null)
      {
          $this-&gt;_require_login();
          $this-&gt;load-&gt;model('todo_model');
          if ($id != null) {
              $result = $this-&gt;todo_model-&gt;get([
                  'id' =&gt; $id,
                  'id_user' =&gt; $this-&gt;session-&gt;userdata('id_user')
              ]);
          } else {
              $result = $this-&gt;todo_model-&gt;get([
                  'id_user' =&gt; $this-&gt;session-&gt;userdata('id_user')
              ]);
          }
  
          return $result;
      }
  </code></pre>
  
  <p><strong>OTHER CONTROLLER</strong></p>
  
  <pre><code> public function index()
      {
          require('api.php');
          $api = new api();
          $query = $api-&gt;get_todo();
  
          $this-&gt;load-&gt;view('dashboard/inc/header_main_view', $query);
          $this-&gt;load-&gt;view('dashboard/admin_pages/dashboard_view');
          $this-&gt;load-&gt;view('dashboard/inc/footer_main_view');
  
      }
  </code></pre>
  
  <p><strong>MODEL</strong></p>
  
  <pre><code> public function get($id = null, $order_by = null)
      {       
          if (is_numeric($id)) {
              $this-&gt;db-&gt;where($this-&gt;_primary_key, $id);
          } 
  
          if (is_array($id)) {
              foreach ($id as $_key =&gt; $_value) {
                  $this-&gt;db-&gt;where($_key, $_value);
              }
          }
  
          $q = $this-&gt;db-&gt;get($this-&gt;_table);
          return $q-&gt;result_array();
      }
  </code></pre>
  
  <p>Can someone please tell me why I am getting the error.</p>