title: How to show null data when data does not exist in database using codeigniter
body: <p>I am joining two tables, and i want to show data when id of both is equal. And when id is not equal so show nothing, but it is showing everything.</p>
  
  <p>This is my Controller</p>
  
  <pre><code>&lt;?php
  
  /**
  * 
  */
  class profile extends CI_Controller
  {
  
      function __construct()
      {
          parent::__construct();
      }
  
      function index()
      {
           $this-&gt;load-&gt;model("profile_model");
           $data['profile_records']=$this-&gt;profile_model-&gt;getAllRecords();
  
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>This is my Model</p>
  
  <pre><code>&lt;?php
  
  /**
  * 
  */
  class profile_model extends CI_Model
  {
  
      function __construct()
      {
          parent::__construct();
  }
  
      function getAllRecords()
      {
  
  
          $this-&gt;db-&gt;select('*');
          $this-&gt;db-&gt;from('ads AS A');// I use aliasing make things joins easier
          $this-&gt;db-&gt;join('membership AS C', 'C.id = A.ad_id', 'INNER');
          $this-&gt;db-&gt;where('A.ad_id  = C.ad_fk'); 
  
               $q = $this-&gt;db-&gt;get("ads");
              if($q-&gt;num_rows() &gt; 0)
              {
                 return $q-&gt;result();
              }
              return array();
      }
  }
  ?&gt; 
  </code></pre>
  
  <p>This is my views</p>
  
  <pre><code>&lt;?php
  
  
  
  
  foreach ($profile_records as $profile_rows)
  {
  ?&gt;
  
  &lt;span&gt;
  
  
      echo "&lt;span class='title2'&gt;". $profile_rows-&gt;ad_timestamp ."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
      &lt;?php  echo "&lt;span class='title2'&gt;". $profile_rows-&gt;ad_title ."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
      &lt;?php  echo "&lt;span class='title'&gt;". $profile_rows-&gt;ad_description ."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
      &lt;?php  echo "&lt;span class='title2'&gt;". $profile_rows-&gt;cat_type ."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
      &lt;?php  echo "&lt;span class='title2'&gt;". $profile_rows-&gt;ad_name ."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
      &lt;?php  echo "&lt;span class='description'&gt;". $profile_rows-&gt;ad_phone ."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
      &lt;?php  echo "&lt;span class='name'&gt;". $profile_rows-&gt;ad_address ."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
      &lt;?php  echo "&lt;span class='phone'&gt;". $profile_rows-&gt;ad_flag."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
      &lt;?php  //echo "&lt;span class='website'&gt;". $row-&gt;address ."&lt;/span&gt;"."&lt;br/&gt;";?&gt;
  &lt;/span&gt;
  &lt;hr width="600px" /&gt;
  &lt;?php }?&gt;
  </code></pre>
  
  <p>How to show null data when data does not exist in database using codeigniter</p>