title: Pass array value to colspan to create column table in php
body: <p>I am having a problem to pass a value from array to colspan, so I can have    dynamic multi column.</p>
  
  <pre><code>$my_values = array();
  while ($data=mysqli_fetch_assoc($result)) {
   foreach ($data as $key =&gt; $value) {
     $my_values[] = $value;
   }
  }
  print_r($my_values);
  </code></pre>
  
  <p>and this is the output the I got for printing the $my_values:</p>
  
  <pre><code>Array ( [0] =&gt; 3 [1] =&gt; 2 [2] =&gt; 1 )
  </code></pre>
  
  <p>What I am trying to do here is creating table and pass those array to colspan:</p>
  
  <pre><code>$query = "SELECT * FROM assignments WHERE course_id=1";
          $result1 = mysqli_query($conn, $query);
          if (mysqli_num_rows($result1) != 0) {
          while ($row=mysqli_fetch_assoc($result1)) {
            echo '&lt;th colspan="'.$my_values['0'].'"&gt;'.$row['assignment_name'].'&lt;/th&gt;';
          }
        }
  </code></pre>
  
  <p>where is <code>$my_values['0']</code> will get just 3. what I am trying to do here is I want to get index 0 first, then index 2 then index 3. so the first one can create 3 columns and the second one 2 columns and the third 1 columns.</p>
  
  <p>can you help me guys with this issue?</p>