title: Codeigniter View Undefined Variable Error
body: <p>I have a program that used to manage items in a store. Everything is working fine. Then I need to get a report referred to <code>update_stock_id</code> for issued items.</p>
  
  <p>Tried the following code</p>
  
  <h1>Controller</h1>
  
  <pre><code>class Reports extends FZ_Controller
  {
  
      function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;library('form_validation');
  
          $this-&gt;load-&gt;model('Report_model');
  
      }
  public function printIssuedItems($id)
      {
          $data['issuedDetail'] = $this-&gt;Report_model-&gt;printIssuedItemData($id);
          $this-&gt;load-&gt;view('reports/printIssuedItems', $data);
      }
  }
  </code></pre>
  
  <h1>Model</h1>
  
  <pre><code>function printIssuedItemData($id)
      {
          $this-&gt;db-&gt;select('store_update_stock.request_no, store_update_stock.billed_date, tbl_user.username,store_item.item_name,
          sum(store_update_stock_details.r_qty) as r_qty, sum(store_update_stock_details.ap_qty) as ap_qty,
          sum(store_update_stock_details.is_qty) as is_qty');
          $this-&gt;db-&gt;from('store_update_stock');
          $this-&gt;db-&gt;join('store_update_stock_details', 'store_update_stock.update_stock_id=store_update_stock_details.update_stock_id');
          $this-&gt;db-&gt;join('tbl_user', 'store_update_stock.supplier=tbl_user.userId');
          $this-&gt;db-&gt;join('store_item', 'store_update_stock_details.item=store_item.item_id', 'right');
          $this-&gt;db-&gt;where(array('store_update_stock.update_stock_id' =&gt; $id, 'store_update_stock_details.status' =&gt; 1));
          $this-&gt;db-&gt;group_by('store_update_stock_details.item');
  
          $q = $this-&gt;db-&gt;get();
          if ($q-&gt;num_rows() &gt; 0) {
              return $q-&gt;result();
          }
          return false;
  
  
      }
  </code></pre>
  
  <h1>View (Relevant part of)</h1>
  
  <pre><code>&lt;?php
  if (!empty($issuedDetail)) {
      $issuedData = $issuedDetail[0];
  }
  ?&gt;
  
  &lt;div class="col-xs-12"&gt;
              &lt;h2 class="page-header"&gt;
  
                  &lt;small class="text-center"&gt; Request No: &lt;b&gt;&lt;?=$issuedData-&gt;request_no?&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                  Request Date: &lt;b&gt;&lt;?=$issuedData-&gt;billed_date?&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                  Officer Name: &lt;b&gt;&lt;?=$issuedData-&gt;username?&gt;&lt;/b&gt;&lt;/small&gt;
              &lt;/h2&gt;
       &lt;/div&gt;
  </code></pre>
  
  <p>The model outs the correct result set. But executing the view, the following error message displays.</p>
  
  <blockquote>
    <p>A PHP Error was encountered<br>
    Severity: Notice<br>
    Message: Undefined variable: issuedData<br>
    Filename: reports/printIssuedItems.php<br>
    Line Number: 52<br></p>
  </blockquote>
  
  <p>Backtrace:</p>
  
  <blockquote>
    <p>File:<br> C:\xampp\htdocs\wpsstores\application\views\reports\printIssuedItems.php<br>
    Line: 52<br>
    Function: _error_handler<br></p>
  </blockquote>
  
  <p>This refers to the variable <code>$issuedData</code>.</p>
  
  <p>I have checked every part of the code. But didn't identify any issue. </p>