title: Insert fetching the array data to new database
body: <p>I am trying to SELECT rows of data from MYSQL and to INSERT it as rows of array to NEW DATABASE with some additional data.
  Please help, this script is not working:</p>
  
  <pre><code>// there is some script and here goes fetching-inserting script:
  &lt;?php
  include ('connection.php');
  $query="SELECT * from savatcha where mem_id='$mem_id' ORDER BY nomination ASC";
  $result=mysql_query($query);
  $num=mysql_numrows($result); 
  mysql_close();
  $i=0;
  $grand_total=0;
  while ($i &lt; $num) 
  {
    $savatcha_id=mysql_result($result, $i, "savatcha_id");
    $s_mem_id=mysql_result($result, $i, "s_mem_id");
    $mem_id=mysql_result($result, $i, "mem_id");
    $tovar_id=mysql_result($result, $i, "tovar_id");
    $nomination=mysql_result($result, $i, "nomination");
    $price=mysql_result($result,$i,"price");
    $quantity=mysql_result($result,$i,"quantity");
    $total_row=$price * $quantity;
    $grand_total += $total_row;
  ?&gt;
  &lt;?php
    include ('order_connection.php');
    mysql_query("INSERT INTO order_list(order_id, s_mem_id, mem_id, firm_name, grand_total, order_method, order_date)VALUES('$order_id', '$s_mem_id', '$mem_id', '$firm_name', '$grand_total', 'Bank hisob raqami orqali', '$date')");
    mysql_close();
  ?&gt;
  &lt;?php
    ++$i;
  }
  ?&gt;
  </code></pre>