title: Build SELECT query with dynamic number of LIKE conditions as a mysqli prepared statement
body: <p>I am trying to write prepared statement for user input. parameter numbers are variable depends on user input. Oam trying this code</p>
  <p>PHP code:</p>
  <pre><code>$string          = &quot;my name&quot;;
  $search_exploded = explode( &quot; &quot;, $string );
  $num             = count( $search_exploded );
  $cart            = array();
  for ( $i = 1; $i &lt;= $num; $i ++ ) {
      $cart[] = 's';
  }
  $str          = implode( '', $cart );
  $inputArray[] = &amp;$str;
  $j            = count( $search_exploded );
  for ( $i = 0; $i &lt; $j; $i ++ ) {
      $inputArray[] = &amp;$search_exploded[ $i ];
  }
  print_r( $inputArray );
  foreach ( $search_exploded as $search_each ) {
      $x ++;
      if ( $x == 1 ) {
          $construct .= &quot;name LIKE %?%&quot;;
      } else {
          $construct .= &quot; or name LIKE %?%&quot;;
      }
  }
  $query = &quot;SELECT * FROM info WHERE $construct&quot;;
  $stmt  = mysqli_prepare( $conn, $query );
  call_user_func_array( array( $stmt, 'bind_param' ), $inputArray );
  if ( mysqli_stmt_execute( $stmt ) ) {
  
      $result = mysqli_stmt_get_result( $stmt );
      if ( mysqli_num_rows( $result ) &gt; 0 ) {
          echo $foundnum = mysqli_num_rows( $result );
          while( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) ) {
  
              echo $id = $row['id'];
              echo $name = $row['name'];
          }
      }
  }
      
  </code></pre>
  <p>When I <code>print_r($inputArray)</code>, the output is:</p>
  <pre><code>Array ( [0] =&gt; ss [1] =&gt; my [2] =&gt; name ) 
  </code></pre>
  <p>There is no error showing in error log.</p>
  <p>What is wrong?</p>