title: Parsing External Table Arguments in Wordpress
body: <p>I have a client project that has posts assigned to their country of origin.</p>
  
  <p>The client wants to be able to search the posts by continent and or region. </p>
  
  <p>I have a separate table that assigns each country to its respective region, and I have the WP query that uses the resulting array:</p>
  
  <pre><code>$country_names = array('England','France','Germany',...); // this would be the result from fetching countries associated with a region.
  $args = array(
      'posts_per_page' =&gt; -1,
      'meta_query' =&gt; array(
          array(
              'key' =&gt; 'country',
              'value' =&gt; $country_names,
              'compare' =&gt; 'IN'
          )
      )
  );
  $query = new WP_Query( $args );
  </code></pre>
  
  <p>What I'm having trouble with is the part in the middle.  Normally, I'd use some standard PHP/MySQL to craft the array:</p>
  
  <pre><code>&lt;?php
  
  //Process incoming variable
  if(!empty($_REQUEST['region'])){
   $region = $_REQUEST['region'];
   } else {
   $region = NULL;
   }
  
  // Make a MySQL Connection
  $query = "SELECT * FROM regions WHERE region='$region'"; 
  
  $result = mysql_query($query) or die(mysql_error());
  
  $row = mysql_fetch_array($result) or die(mysql_error());
  echo $row['country'];
  ?&gt;
  </code></pre>
  
  <p>However, I'm having trouble making it work within a WP template, since WP manages the incoming variables using its own internal functions. </p>
  
  <p>Can anyone help me to connect the two together? I'm sure I'm overlooking some simple step here, or else I'm not using some built-in WP function.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>ty</p>