title: how to select one result from and array to put on ifelse condition in codeigniter/php?
body: <p>am trying to do the display a dive based on a result retrieved from db. the query should select all students and see if there is any one who has value one then it can display the div if not then the div should no be displayed.
  this is for leaderboard/ wall of fame. so in database there is only one record that has value 1 and rest is 0<br>
  the problem with the following code its not giving the right result </p>
  
  <pre><code>&lt;?php
      $query = $this-&gt;db-&gt;query("SELECT * FROM student");
      foreach ($query-&gt;result() as $row)
      {
         echo $row-&gt;leaderboard;
         $field= $row-&gt;leaderboard;
      }
  
      if ($field != 1) :
  ?&gt;
  
   &lt;div class="col-sm-6" style="display:none"  &gt;
   &lt;?php  elseif ($field = 1): ?&gt;                 
       &lt;div class="col-sm-6"  &gt;
   &lt;?php endif; ?&gt;
  </code></pre>