title: How to insert multiple radio button values with PHP OOP
body: <p>I'm working on a <code>CMS</code> with <code>PHP</code> <code>OOP</code>. In this project, there is a feature for users to add new Telegram Channel. For this feature, I added this form which also contains the action codes: </p>
  
  <pre><code>    &lt;?php 
  if(isset($_POST['submit'])){
      $token = $_POST['token'];
      $cat = $_POST['cat'];
      $ads = $_POST['ads'];
      $key = $_POST['keyboard'];
      $tel = new Telegram();
      $notice = $tel-&gt;AddNew($token,$cat,$ads,$key);
  }
  ?&gt;
  &lt;div class='content-wrapper'&gt;
      &lt;section class='content-header'&gt;
          &lt;h1&gt;
              Add New Telegram Account
              &lt;small&gt;You can add a new Telegram channel here&lt;/small&gt;
          &lt;/h1&gt;
          &lt;ol class='breadcrumb'&gt;
              &lt;li class='active'&gt;telegram.php&lt;/li&gt;
          &lt;/ol&gt;
      &lt;/section&gt;
      &lt;?php 
      if($dataSet-&gt;GetLevel()==1)
      { echo "
          &lt;section class='content'&gt;
              &lt;div class='row'&gt;
                  &lt;div class='col-md-6'&gt;
                      &lt;div class='box box-primary'&gt;
                          &lt;div class='box-header with-border'&gt;
                              &lt;h3 class='box-title'&gt;Required Information&lt;/h3&gt;
                          &lt;/div&gt;
                          ";
                          if(isset($notice['success_message'])){
                              echo "
                                  &lt;div class='alert alert-success'&gt;
                                      &lt;strong&gt;Hey!&lt;/strong&gt; ".$notice['success_message'].".
                                  &lt;/div&gt;
                              ";
                          }
                          echo "
                          &lt;form role='form' method='POST' action=''&gt;
                              &lt;div class='box-body'&gt;
                                  &lt;div class='form-group'&gt;
                                      &lt;label&gt;Token Number&lt;/label&gt;
                                      &lt;input type='text' class='form-control' placeholder='Enter token' name='token' required&gt;
                                      &lt;a href='#' style='color:purple;'&gt;Having problem while getting token&lt;/a&gt;
                                  &lt;/div&gt;
                                  &lt;div class='form-group'&gt;
                                      &lt;label&gt;Select Category&lt;/label&gt;
                                      &lt;select name='cat' class='form-control'&gt;
                                          &lt;option value='empty'&gt;---&lt;/option&gt;
                                          &lt;option value='technology'&gt;Technology&lt;/option&gt;
                                          &lt;option value='4fun'&gt;Game &amp; Fun&lt;/option&gt;
                                          &lt;option value='news'&gt;News&lt;/option&gt;
                                          &lt;option value='tools'&gt;Tools&lt;/option&gt;
                                          &lt;option value='learning'&gt;Learning&lt;/option&gt;
                                          &lt;option value='traditional'&gt;Traditional&lt;/option&gt;
                                          &lt;option value='media'&gt;Media&lt;/option&gt;
                                      &lt;/select&gt;
                                  &lt;/div&gt;
                                  &lt;div class='form-group'&gt;
                                      &lt;div class='radio'&gt;
                                          &lt;label&gt;
                                              &lt;input type='radio' name='ads' id='optionsRadios1' value='on' checked&gt;
                                              Set ads on&lt;/br&gt;
                                              &lt;input type='radio' name='ads' id='optionsRadios1' value='off'&gt;
                                              Set ads off
                                          &lt;/label&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class='form-group'&gt;
                                      &lt;div class='checkbox'&gt;
                                          &lt;label&gt;
                                              &lt;input type='checkbox' name='keyboard' value='with_keyboard'&gt;
                                              Use dedicated keyboard for this bot
                                          &lt;/label&gt;&lt;/br&gt;
                                          &lt;label&gt;
                                              &lt;input type='checkbox' name='keyboard' value='without_keyboard'&gt;
                                              Show keyboard at groups
                                          &lt;/label&gt;&lt;/br&gt;
                                          &lt;label&gt;
                                              &lt;input type='checkbox' name='answer' value='answer_messages_chats' checked&gt;
                                              In private chats, just anwser the pre defined messages
                                          &lt;/label&gt;&lt;/br&gt;
                                          &lt;label&gt;
                                              &lt;input type='checkbox' name='answer' value='answer_messages_groups' checked&gt;
                                              In groups, just answer the pre defined messages
                                          &lt;/label&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class='box-footer'&gt;
                                  Visit &lt;a href='https://zite.pouyavagefi.com/documentation/telegram.php'&gt;Telegram&lt;/a&gt; Social Media Documentation.
                              &lt;/div&gt;
                              &lt;div class='box-footer'&gt;
                                  &lt;button name='submit' type='submit' class='btn btn-primary'&gt;Submit&lt;/button&gt;
                              &lt;/div&gt;
                          &lt;/form&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/section&gt; "; 
      }else{
          echo "
          &lt;section class='content'&gt;
              &lt;div class='alert alert-warning'&gt;
                  &lt;strong&gt;Access Denied!&lt;/strong&gt; You don\'t have permission to access this page.
              &lt;/div&gt; 
          &lt;/section&gt; "; 
      }
      ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>As you can at the top, I have called a class which is called <code>Telegram.class.php</code> and this class goes like this:</p>
  
  <pre><code>    &lt;?php 
  class Telegram
  {   
      protected $notice = array();
      private $db;
      public function __construct()
      {
          $this-&gt;db = new Connection();
          $this-&gt;db = $this-&gt;db-&gt;dbConnect();
      }
      public function AddNew($token,$cat,$ads,$key)
      {
          if(!empty($token)&amp;&amp;!empty($cat)&amp;&amp;!empty($ads))
          {
              for ($i=0;$i&lt;sizeof($ads);$i++)
              {
                  for ($i=0;$i&lt;sizeof($key);$i++)
                  {
                      $new = $this-&gt;db-&gt;prepare("INSERT INTO channels (token_number, category_name, ads_set, keyboard_status) VALUES (?, ?, "/*.$ads[$i].*/", "/*.$key[$i].*/")");
                      $new-&gt;bindParam(1,$token);
                      $new-&gt;bindParam(2,$cat);
                      $new-&gt;bindParam(3,$ads);
                      $new-&gt;bindParam(4,$key);
                      $new-&gt;execute();
                      $notice['success_message'] = "New Telegram Channel was successfully added";
                      return $this-&gt;notice;
                  }
              }
  
          }
      }
      public function getNotice()
      {
          return $this-&gt;notice;
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Because I want to add multiple checkboxes into table, I used this for loop inside the method <em>Add_New</em> (According to this <a href="https://stackoverflow.com/questions/25295516/insert-radio-button-value-to-mysql">question</a>):</p>
  
  <pre><code>for ($i=0;$i&lt;sizeof($ads);$i++)
          {
              for ($i=0;$i&lt;sizeof($key);$i++)
              {
                  $new = $this-&gt;db-&gt;prepare("INSERT INTO channels (token_number, category_name, ads_set, keyboard_status) VALUES (?, ?, "/*.$ads[$i].*/", "/*.$key[$i].*/")");
                  $new-&gt;bindParam(1,$token);
                  $new-&gt;bindParam(2,$cat);
                  $new-&gt;bindParam(3,$ads);
                  $new-&gt;bindParam(4,$key);
                  $new-&gt;execute();
                  $notice['success_message'] = "New Telegram Channel was successfully added";
                  return $this-&gt;notice;
              }
          }
  </code></pre>
  
  <p>I know it's not correct but I don't know the right way to add these <strong>$ads[$i]</strong> and <strong>$key[$i]</strong> variables into the <em>insert</em> statement... </p>
  
  <p>So if you know how to do this in the correct order, please let me know.. thanks!</p>