title: How to show data using codeigniter or mysql query from my example
body: <p>My Example Tables are below,</p>
  
  <p><img src="https://i.stack.imgur.com/AJU6M.jpg" alt="enter image description here"></p>
  
  <pre><code>$hdn_roll[0] =0;
  $i =0;
  foreach($results as $row):
     $i++;
     $roll = $row-&gt;roll;
     $questions       = $row-&gt;questions;
     $hdn_roll[$i] = $roll;
     $count_ad = array_count_values($hdn_roll);
     $count_sp = $count_ad[$hdn_roll[$i]];
  
     $j = 0;
     if($hdn_roll[$i] != $hdn_roll[($i-1)]):
  
       if($count_sp ==1):
           create_row_after_balloting($roll,$questions);
       endif;
     else:
        $j++;
  
        $data['roll'.$j]          = $roll;
  
        $data['questions'.$j]     = $questions;
     endif;
  
  endforeach;
  </code></pre>
  
  <p>Actually, I want to display Like Table:B from Table:A(MySQL Database).</p>
  
  <p>Above Code, I can display 1001 to 1009 but Remain 1003,1006,1008,1006 are not display. 
  On the other hand, Same Roll Can't stay another(1003) after one(1003)</p>
  
  <p>How can i solve it in PHP code or MySQL Query.</p>