title: How to bind mysqli parameters using loop and store results in array?
body: <pre><code>$genre = array(
      'Action',
      'Adventure',
      'Fantasy'
  );
  $selectGenre_sql = 'SELECT genreID FROM genres WHERE dbGenre = ?';
  
  if ($stmt-&gt;prepare($selectGenre_sql)) {
      // bind the query parameters
      $stmt-&gt;bind_param('s', $genre);
      // bind the results to variables
      $stmt-&gt;bind_result($genres);
      // execute the query
      $stmt-&gt;execute();
      $array1 = array();
      while ($stmt-&gt;fetch()) {
          $array1[] = $genres;
      }
  }
  </code></pre>
  <p>The code above gets the value from <code>genreID</code> when <code>dbGenre</code> is equal to <code>$genre</code>. And then store the results in an array. But it's not working because <code>$genre</code> is an array, so I need to loop through it to get a different value from <code>genreID</code> each time.</p>
  <p>The 'genres' table contains two columns: <strong>genreID (INT)</strong> and <strong>dbGenre (VARCHAR)</strong></p>
  <p>I just need each genreID (that is a number)... Let's say when dbGenre is equal to Action, then store the genreID in an array1, and then loop the $genre array to get the genreID for the next value and store it again in array1.</p>
  <p>How can I fix it?</p>