title: Select query using array IN() and echo results in custom named textfields
body: <p>I have two tables <code>table_users</code> and <code>table_items</code>. <code>table_users</code> holds in several columns item ID's. <code>table_items</code> holds the item ID's with the related properties. Purpose is to fetch the item ID's from <code>table_users</code> and subsequently look up these item ID's in <code>table_items</code> and echo the results in a html textfield.</p>
  
  <p>I have an array made of variables. The variables are the result of a query to fetch the item ID's from <code>table_users</code>.</p>
  
  <pre><code>$item1 = $row['item1'];
  $item2 = $row['item2'];
  $item3 = $row['item3'];
  
  $array = array($item1, $item2, $item3);
  </code></pre>
  
  <p>To fetch data from table <code>table_items</code> I use the following query (I know PDO would be better):</p>
  
  <pre><code>$sql = "SELECT * FROM table_items WHERE itemID IN (".implode(',',$array).")";
  $result = mysqli_query($connection,$sql) or die ("couldn’t execute query: ".mysqli_error($connection));
  $data = mysqli_fetch_assoc($result);
  </code></pre>
  
  <p>For each column of table_users I want to echo a textfield with a name that refers to the column and the property (ex. if column is called item1, the textfield name should contain "item1" and the name of the property). The value of that text field is <code>$data['column name of table_items']</code>.
  so echo something like <code>echo "&lt;input type='text' name='txt???????' value='".$data['column name of table_items']."'&gt;";</code></p>
  
  <p>Question is, how do I get the right value from <code>table_items</code> and echo it in a correctly named textfield? And do this for all variables in array <code>$array</code>?</p>
  
  <p><strong>Clarification with example</strong></p>
  
  <p>in <code>table_user</code> I have the columns "guitar", "bass", "percussion" that contains as reference the ID of the instrument in <code>table_items</code> . In <code>table_items</code>, I have a for whole bunch of guitars, bass, and drum kits the ID, brand, type and price. Lets say user X has a Fender Stratocaster of 1500$, a Musicman Stingray of 2000$ and a Sonor Vintage Series of 2200$.
  I want the output of the script to be textfield txtGuitarBrand with value Fender, txtGuitarType with value Stratocaster, txtGuitarPrice with value 1500, txtBassBrand with value Musicman,... and so on.</p>
  
  <p>I don't know if it's something I have to do in "query" part or something in the "echo" part or both.</p>