title: PHP - Multiple MySQL result, in separate variables
body: <p>I need to do a MySQL query to search for an inexact match / match containing the submitted value.</p>
  
  <p>The following is an example of what is in my database:</p>
  
  <pre><code>id               img
  1          1001_ABC_01.jpg
  2          1001_ABC_02.jpg
  3          1002_ABC_01.jpg
  4          1002_ABC_02.jpg
  5          1002_ABC_03.jpg
  6          1002_ABC_04.jpg
  7          1002_ABC_05.jpg
  8          1003_ABC_01.jpg
  9          1003_ABC_02.jpg
  10         1003_ABC_03.jpg
  </code></pre>
  
  <p>I need the query to search for the first part of the filename (<code>1002</code>) and and assign each returned result in the img field a different variable. The maximum amount of variables would be 5.</p>
  
  <p>For example, if I search <code>1002</code>, it should assign the following variables:</p>
  
  <pre><code>    &lt;?php
      $img1 = '1002_ABC_01.jpg';
      $img2 = '1002_ABC_02.jpg';
      $img3 = '1002_ABC_03.jpg';
      $img4 = '1002_ABC_04.jpg';
      $img5 = '1002_ABC_05.jpg';
      ?&gt;
  </code></pre>
  
  <p>so that way I can echo each filename result individually.</p>
  
  <p>Again, the maximum amount of variables here will be 5, so if more than 5 results are returned, only the first 5 will be assigned variables.</p>
  
  <p>Please let me know if this is possible and how to write a PHP script to do it.</p>