title: Create table column headers from selected values of a drop down list
body: <p>I am using this <a href="http://www.webslesson.info/2017/04/multiple-select-option-by-using-bootstrap-select-plugin-in-php-ajax.html" rel="nofollow noreferrer">example</a> of a multiple selection dropdown list</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;Webslesson Tutorial | How to Use Bootstrap Select Plugin with PHP JQuery&lt;/title&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /&gt;
    &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css"&gt;
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"&gt;&lt;/script&gt;
  
   &lt;/head&gt;
   &lt;body&gt;
    &lt;br /&gt;&lt;br /&gt;
    &lt;div class="container"&gt;
     &lt;br /&gt;
     &lt;h2 align="center"&gt;How to Use Bootstrap Select Plugin with PHP JQuery&lt;/h2&gt;
     &lt;br /&gt;
     &lt;div class="col-md-4" style="margin-left:200px;"&gt;
      &lt;form method="post" id="multiple_select_form"&gt;
       &lt;select name="framework" id="framework" class="form-control selectpicker" data-live-search="true" multiple&gt;
        &lt;option value="Laravel"&gt;Laravel&lt;/option&gt;
        &lt;option value="Symfony"&gt;Symfony&lt;/option&gt;
        &lt;option value="Codeigniter"&gt;Codeigniter&lt;/option&gt;
        &lt;option value="CakePHP"&gt;CakePHP&lt;/option&gt;
        &lt;option value="Zend"&gt;Zend&lt;/option&gt;
        &lt;option value="Yii"&gt;Yii&lt;/option&gt;
        &lt;option value="Slim"&gt;Slim&lt;/option&gt;
       &lt;/select&gt;
       &lt;br /&gt;&lt;br /&gt;
       &lt;input type="hidden" name="hidden_framework" id="hidden_framework" /&gt;
       &lt;input type="submit" name="submit" class="btn btn-info" value="Submit" /&gt;
      &lt;/form&gt;
      &lt;br /&gt;
  
     &lt;/div&gt;
    &lt;/div&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;script&gt;
  $(document).ready(function(){
   $('.selectpicker').selectpicker();
  
   $('#framework').change(function(){
    $('#hidden_framework').val($('#framework').val());
   });
  
   $('#multiple_select_form').on('submit', function(event){
    event.preventDefault();
    if($('#framework').val() != '')
    {
     var form_data = $(this).serialize();
     $.ajax({
      url:"insert.php",
      method:"POST",
      data:form_data,
      success:function(data)
      {
       //console.log(data);
       $('#hidden_framework').val('');
       $('.selectpicker').selectpicker('val', '');
       alert(data);
      }
     })
    }
    else
    {
     alert("Please select framework");
     return false;
    }
   });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>It works fine but I am trying to adjust the code mentioned on the page according my needs. I want to create a dynamic table with columns name what i selected from the Dropdown list</p>
  
  <p>so instead of creating the table manually and giving names of the columns as my code here </p>
  
  <pre><code>&lt;?php   
  
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);
  
  
      $ser="10.90.294.23";
      $db="Framework"; 
      $user="test"; 
      $pass="test0";
      $query = 'SELECT Laravel, Symfony, Codeigniter, CakePHP FROM Framework.list';
  
      $dbDB = new PDO("odbc:Driver=ODBC Driver 13 for SQL Server;Server=10.90.294.23,1456;Database=Framework;Port=1456", $user, $pass);
  
       ?&gt;  
       &lt;!DOCTYPE html&gt;  
       &lt;html&gt;  
            &lt;head&gt;  
                 &lt;title&gt;HTML table using Jquery with PHP&lt;/title&gt;  
                 &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt;  
                 &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /&gt;  
                 &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;  
            &lt;/head&gt;  
            &lt;body&gt;  
                 &lt;br /&gt;  
                 &lt;div class="container" style="width:700px;"&gt;  
                      &lt;h3 class="text-center"&gt;HTML table using Jquery with PHP&lt;/h3&gt;&lt;br /&gt;  
                      &lt;div class="table-responsive" id="employee_table"&gt;  
                           &lt;table class="table table-bordered"&gt;  
                                &lt;tr&gt;  
                                     &lt;th width="10%"&gt;Laravel&lt;/th&gt;  
                                     &lt;th width="30%"&gt;Symfony&lt;/th&gt;  
                                     &lt;th width="10%"&gt;Codeigniter&lt;/th&gt;  
                                     &lt;th width="50%"&gt;CakePHP&lt;/th&gt;  
                                &lt;/tr&gt;  
                              &lt;?php   
      foreach ($dbDB-&gt;query($query) as $row) {
                                ?&gt;  
                                &lt;tr&gt;  
                                     &lt;td&gt;&lt;?php echo $row['Laravel']; ?&gt;&lt;/td&gt;  
                                     &lt;td&gt;&lt;?php echo $row['Symfony']; ?&gt;&lt;/td&gt;  
                                     &lt;td&gt;&lt;?php echo $row['Codeigniter']; ?&gt;&lt;/td&gt;  
                                     &lt;td&gt;&lt;?php echo $row['CakePHP']; ?&gt;&lt;/td&gt;  
                                &lt;/tr&gt;  
                                &lt;?php                           
                                }  
                                ?&gt;  
                           &lt;/table&gt;  
                      &lt;/div&gt;   
                 &lt;/div&gt;  
                 &lt;br /&gt;  
            &lt;/body&gt;  
       &lt;/html&gt;  
  </code></pre>
  
  <p>I want the columns headers will be created automatically from the selected values. 
  I was thinking about storing the selected value in variable for example : Laravel,CakePHP,Yii,Slim then I create the header based on each text between the comma ","</p>
  
  <p>Can anyone help with this please ? I have tried many ways but still can't make it work. Thank you.</p>