title: display default image if user have no photo codeigniter
body: <p>In displaying my image getting it from the database is fine but I want to display the default image if no user hasn't uploaded a photo yet. I saved a no-avatar.jpg to my /uploads folder</p>
  <br>
  <br>
  <p>Here is my display user image.</p>
  <blockquote>
  <p>view</p>
  </blockquote>
  <pre><code>&lt;img height=&quot;180px&quot; width=&quot;180px&quot;class=&quot;ppborder&quot; src=&quot;&lt;?php echo base_url().'/uploads/'.$this-&gt;session-&gt;userdata('image'); ?&gt;&quot;&gt; 
  </code></pre>
  <blockquote>
  <p>upload</p>
  </blockquote>
  <pre><code>public function updatephoto($id)
      {
      if ((int)$id &lt; 1)//$id is not an integer
      {
      redirect('Memberlogincontroller/member_view', 'refresh');
      }
      else{
      $this-&gt;load-&gt;helper(array('form','file','url'));
      $this-&gt;load-&gt;library('form_validation');
      $config_image = array(
          'upload_path'   =&gt; './uploads/',
          'allowed_types' =&gt; 'gif|jpg|png',
          'max_size'      =&gt; '1024',
          'overwrite'     =&gt; true
    
      );
      $this-&gt;load-&gt;library('upload', $config_image);
  
      if($this-&gt;form_validation-&gt;run()==false and empty($_FILES['userfile']['name'][0]))
          {
              $id = $this-&gt;session-&gt;userdata('id');
              $memberinfo = array(
                  'error_image' =&gt; ''
              );
          $this-&gt;session-&gt;set_flashdata('flashError', 'Oops no photo selected', $memberinfo);         
          redirect('index.php/Memberlogincontroller/editphoto/'.$id, 'refresh');
          }       
      else
          {           
              $this-&gt;upload-&gt;do_upload();
               $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
               $this-&gt;image_resize($data['upload_data']['full_path'], $data['upload_data']['file_name']);
               $id = $this-&gt;session-&gt;userdata('id');
               $this-&gt;db-&gt;where('id', $id);
               $query = $this-&gt;db-&gt;get('member'); 
              $data = array(
                  'image' =&gt; $data['upload_data']['file_name']    
          );
          $this-&gt;db-&gt;update('member',$data,array('id'=&gt;$id));          
          $this-&gt;session-&gt;set_userdata($data); 
          $this-&gt;session-&gt;set_flashdata('flashSuccess', 'Your photo has been updated.');
          redirect('index.php/Memberlogincontroller/getMember/'.$id, 'refresh');       
      }       
      }
      }
  </code></pre>
  <p>How to display my default image?</p>