title: codeigniter check box value
body: <p>hello everyone I just started working with codeigniter and php. I am making a simple survey type website whit check-boxes the questions are going to be multiple choice and the results will be stored in a database if a check-box is checked. my question is how would I go about of doing that.here is my form and thanks for everyone help in advance.</p>
  
  <p><strong>view</strong></p>
  
  <pre><code>&lt;?php foreach($survay_data as $survay):?&gt; 
      &lt;ul&gt;
          &lt;li&gt;&lt;h1&gt;&lt;?php echo $survay-&gt;Question;?&gt;&lt;/h1&gt;&lt;/li&gt; 
          &lt;li&gt;&lt;?php echo $survay-&gt;qA; ?&gt;&lt;input type="checkbox" name="q1[]" value="qA"&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?php echo $survay-&gt;qB; ?&gt;&lt;input type="checkbox" name="q2[]" value="qB"&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?php echo $survay-&gt;qC; ?&gt;&lt;input type="checkbox" name="q3[]" value="qC"&gt;&lt;/li&gt;
          &lt;?php endforeach; ?&gt;
          &lt;input type="textarea" value='a' name="comment"&gt;
          &lt;br&gt;
          &lt;input type="submit" value="Submit"&gt;
      &lt;/ul&gt;
  </code></pre>
  
  <p><strong>controller</strong></p>
  
  <pre><code>&lt;?php
      class Survay extends CI_Model{
  
          function dosurvay($arrData){
  
              $this-&gt;db-&gt;select('QID, Question, qA, qB, qC');
              $this-&gt;db-&gt;from('tblquestions');
              $this-&gt;db-&gt;where('Question', $arrData['Question']);
              $this-&gt;db-&gt;where('qA', $arrData['qA']);
              $this-&gt;db-&gt;where('qB', $arrData['qB']);
              $this-&gt;db-&gt;where('qC', $arrData['qC']);
              $this -&gt; db -&gt; limit(1);
  
              $query = $this -&gt; db -&gt; get();
  
              if($query -&gt; num_rows() == 1)
              {
                  return $query-&gt;result();
              }
              else
              {
                  return false;
              }
          }
      }
  ?&gt;
  </code></pre>
  
  <p><strong>model</strong></p>
  
  <pre><code>&lt;?php
  class Survaycontroller extends CI_Controller{
     // 'QID, Question, qA, qB, qC'
  
      function index()
      {
  
              $arrData = array();
              $arrData["qA"] = $this-&gt;input-&gt;post("qA");
              $arrData["qB"] = $this-&gt;input-&gt;post("qB");
              $arrData["qC"] = $this-&gt;input-&gt;post("qC");
              $arrData["Question"] = $this-&gt;input-&gt;post("Question");
  
              $this-&gt;load-&gt;model('survay');
  
              $survay_data = $this-&gt;survay-&gt;dosurvay($arrData);
  
              $viewData['survay_data'] = $survay_data;
  
              $this-&gt;load-&gt;view('survay_view', $viewData);
      }
  
  }
  ?&gt;
  </code></pre>