title: how to fetch all rows data from the database using while loop and stored fetch values in variables in php
body: <p>hi everyone i have table in the database from where i fetch data one column of table has user input n i fetch the data on the basis of user input like if user enter 2 in the textbox only that rows that contain number 2 will display 
  like 
  code of insertion on the basis of no of room</p>
  
  <pre><code>   &lt;?php
      $d=$_POST['roomno'];
      echo $d;
      ?&gt;
        &lt;?php
        //database connection
      $db = new PDO("mysql:host=localhost;dbname=ems",'root','');
      //query
      $sql = "INSERT INTO table1 (c,c1, c2, c3, c4,c5,c6,c7,c8,c9,c10,c11,c12,c13) VALUES ('',:c1, :c2, :c3, :c4,:c5, :c6, :c7, :c8, :c9,:c10, :c11, :c12,'$d')";
      $stmt = $db-&gt;prepare($sql);
      foreach ($data_t1 as $i =&gt; $value) {
          $stmt-&gt;execute(array(
             ':c1'=&gt;$data_t1[$i],
             ':c2'=&gt;$data_t2[$i],
             ':c3'=&gt;$data_t3[$i],
             ':c4'=&gt;$data_t4[$i],
             ':c5'=&gt;$data_t11[$i],
             ':c6'=&gt;$data_t22[$i],
             ':c7'=&gt;$data_t33[$i],
             ':c8'=&gt;$data_t44[$i],
             ':c9'=&gt;$data_t111[$i],
             ':c10'=&gt;$data_t222[$i],
             ':c11'=&gt;$data_t333[$i],
             ':c12'=&gt;$data_t444[$i],
          ));
      } ?&gt;
  </code></pre>
  
  <p>coding for fetchng the data</p>
  
  <pre><code> &lt;?php
      include('config.php');
      $sa="select * from table1 where c13='$d'";
      $result=mysql_query($sa) or die(mysql_error());
      echo "&lt;table border='1'&gt;
      &lt;tr&gt;
  
      &lt;/tr&gt;";
  
       &lt;?php
      $i = 1;
      while($row = mysql_fetch_array($result)) {
         echo ${"r" . $i . "1"} = $row['c'];
        echo  ${"r" . $i . "2"} = $row['c1'] ;
         echo ${"r" . $i . "3"} = $row['c2'];
         echo ${"r" . $i . "4"} = $row['c3'];
         echo ${"r" . $i . "5"} = $row['c4'];
         $i++;
      }
  </code></pre>
  
  <p>result </p>
  
  <pre><code>$d=3;mean user enter 3
  3 room deatils enter in three rows of table like ths
  
  row1  2   4  5   6    3(user enter value)
  row2  12  14 15   16   3(user enter value)
  row3  22  44  55  63   3(user enter value)
  </code></pre>
  
  <p>now as i mention in my fetch query that fetch the data where c13(room)=user input($d);</p>
  
  <p>result of theses above three row display</p>
  
  <p>now i want to store each of theses three row values in different varaibles </p>
  
  <p>in the similar manner if user enter 2 or 4 i want to store two or four rows values in different varaible</p>