title: how to bring checkbox values to update page in codeigniter
body: <p>Actually i fetched data successfully but checkbox is not showing checked values. Maybe the logic is wrong. And it is necessary to use foreach here, can't we direct echo in value field, i am new to it and maybe the mistakes are silly </p>
  
  <p>view</p>
  
  <pre><code>&lt;html&gt;
  &lt;?php
  foreach($post_id as $data){
  
       $a=$data-&gt;id;
       $b=$data-&gt;name;
       $c=$data-&gt;email;
       $d=json_decode($data-&gt;skills);
       $e=$data-&gt;notes;
       $f=$data-&gt;gender;
  }
  ?&gt;
  &lt;?php var_dump($d);?&gt;
  &lt;?php var_dump($f);?&gt;
  &lt;body&gt;
  &lt;form method="post" action="&lt;?php echo site_url('Student_info/update'); ?&gt;"&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;ENTER NAME&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="name" value="&lt;?php echo $b;   ?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;ENTER EMAIL &lt;/td&gt;
  &lt;td&gt;&lt;input type="email" name="email" value="&lt;?php echo $c; ?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;ENTER SKILLS&lt;/td&gt;
  &lt;td&gt;
  &lt;input type="checkbox" name="skills[]" value="php" &lt;?php if($d == "php"){echo 'checked="checked"'; } ?&gt;&gt;php&lt;br&gt;
  &lt;input type="checkbox" name="skills[]" value="dotnet" &lt;?php if($d == "dotnet"){echo 'checked="checked"'; } ?&gt; &gt;dotnet&lt;br&gt;
  &lt;input type="checkbox" name="skills[]" value="java" &lt;?php if($d == "java"){echo 'checked="checked"'; } ?&gt;&gt;java&lt;br&gt;
  &lt;input type="checkbox" name="skills[]" value="ruby_on_rails" &lt;?php if($d == "ruby_on_rails"){echo 'checked="checked"'; } ?&gt; &gt;ruby_on_rails&lt;br&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;NOTES&lt;/td&gt;
  &lt;td&gt; &lt;textarea name="notes" rows="4" cols="50"&gt;&lt;?php echo $e; ?&gt;&lt;/textarea&gt; &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;GENDER&lt;/td&gt;
  &lt;td&gt; &lt;input type="radio" name="gender" value="male" &lt;?php if($f == "male"){echo 'selected="selected"'; } ?&gt;&gt; Male&lt;br&gt;
       &lt;input type="radio" name="gender" value="female" &lt;?php if($f == "Female"){echo 'selected="selected"'; } ?&gt;&gt; Female&lt;br&gt; &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="submit" name="add" value="submit"/&gt;&lt;/td&gt;    
  &lt;/tr&gt;  
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>