title: INSERT INTO from SQL Table with specified order
body: <p>I am trying to insert data from one SQL database table into another.  It needs to be inserted in a specified order as I am planning on extracting the data in the table to a csv file to create a catalogue.  I have over 50000 items in my main table and want to extract about 500 into the new table.  </p>
  
  <p>I have created a form to enter the reference number (ref) which creates an array of reference numbers.</p>
  
  <pre><code>  &lt;form action="list.php" method="post"&gt;
            &lt;p&gt;List Number &lt;input name="list_no" type="text"&gt;&lt;/p&gt;
        &lt;table align="center" width="50%"&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;input name="item[]" type="text" style="width: 80px"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input name="item[]" type="text" style="width: 80px"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input name="item[]" type="text" style="width: 80px"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input name="item[]" type="text" style="width: 80px"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input name="item[]" type="text" style="width: 80px"&gt;&lt;/td&gt;
      &lt;/tr&gt;
        &lt;/table&gt;
    &lt;p&gt;Step 4: Create List.&lt;input name="Submit1" type="submit" value="Create List" /&gt;&lt;/p&gt;
  </code></pre>
  
  <p>On list.php I have created the code to create a new table in my database with the name list... depending on the number entered on the form.  My data from the table in assigned to the array  </p>
  
  <pre><code>$item=$_POST['item'];
  </code></pre>
  
  <p>I know the data in $item is in the order I entered it to the form as I have used  $item_list = implode(",", $item); and echo $item_list to check the order of the entered data, and to get the data separated by a comma.</p>
  
  <p>My list.php page then uses the code </p>
  
  <pre><code>$insert="INSERT INTO list$list_no (ref, description, price_s) 
           SELECT ref, description, price_s 
           FROM stock 
          WHERE ref IN ($item_list)";
  </code></pre>
  
  <p><code>mysql_query($insert) or die(mysql_error());</code></p>
  
  <p>to enter the items into the new table.  It enters all items that have been requested, however appears to enter them in order of ref, rather than order of the way I entered them onto the original form.  </p>
  
  <p>Any ideas on how to rectify this problem?</p>
  
  <p>Many Thanks in advance!</p>