title: Displaying Success/Fail message from flashdata in Codeigniter
body: <p>I am trying learn how to display a message to the user informing them of either an error or success message from them attempting to delete a content page from the database. I'm wondering if I"m doing it right so far. If I am what what I do in the view?</p>
  
  <p>Controller </p>
  
  <pre><code>/**
   * Content_pages::delete_content_page()
   * 
   * Deletes a content page from the list of content pages.
   * 
   * @param string $content_page_id The id of the content page being deleted.
   * @return void
   */
  public function delete_content_page($content_page_id)
  {
      $status = 'unprocessed';
      $title = 'Action Unprocessed';
      $message = 'The last action was rendered unprocessed. Please try again.';
      if (isset($content_page_id) &amp;&amp; is_numeric($content_page_id))
      {
          $content_page_data = $this-&gt;content_page-&gt;get($content_page_id);
          if (!empty($content_page_data))
          {
              $this-&gt;content_page-&gt;update($content_page_id, array('status_id' =&gt; 3));
              if ($this-&gt;db-&gt;affected_rows() &gt; 0)
              {
                  $status = 'success';
                  $message = 'The content page has been successfully deleted.';
                  $title = 'Content Page Deleted';   
              }
              else
              {
                  $status = 'error';
                  $message = 'The content page was not deleted successfully.';
                  $title = 'Content Page Not Deleted';   
              }
          }
      }
      $output = array('status' =&gt; $status, 'message' =&gt; $message, 'title' =&gt; $title);
      $this-&gt;session-&gt;set_flashdata('output', $output); 
      redirect('content-pages/list');
  }
  
  /**
   * Content_pages::list_content_pages()
   * 
   * List all of the content pages found in the database.
   * 
   * @return void
   */
  public function list_content_pages()
  {   
      $content_pages = $this-&gt;content_page-&gt;get_all();
  
      $data['output'] = $this-&gt;session-&gt;flashdata('output');
  
      $this-&gt;template
          -&gt;title('Content Pages')
          -&gt;set('content_pages', $content_pages)
          -&gt;build('content_pages_view', $data);    
  }
  </code></pre>
  
  <p>My issue is in the view because it shows up as default empty message so I'm trying to figure out how to not show it when the view first renders and only when there is a message to be displayed.</p>
  
  <pre><code>if (isset($output))
  {
      if ($output['status'] == 'success')
      {
          echo '&lt;div class="alert alert-success"&gt;';
      }
      elseif ($output['status'] == 'error')
      {
          echo '&lt;div class="alert alert-error"&gt;';
      }
      else
      {
          echo '&lt;div class="alert alert-error"&gt;';
      }
  
      echo '&lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;';
      echo '&lt;strong&gt;' . $output['title'] . '&lt;/strong&gt;' . $output['message'];
      echo '&lt;/div&gt;';
  }
  ?&gt;
  </code></pre>