Modify MySQL Query Based on Dropdown Menu

You don’t need to write your own queries, just use wordpress functions.

For instance, to get post by id; use get_post

<form method="POST">
  <select name="post_ID">
    <option value="21">21</option>
    <option value="22">22</option>
  </select>

 <input type="submit" value="Get Selected Value" />
</form>

<?php

 $post_id = $_POST['post_ID'];

 if ( is_int( $post_id ) && !empty ($post_id ) ){

   $post = get_post( $post_id );

   if($post){

      echo '<table>';
      echo "<tr>";
      echo "<th>Header 1</th>";
      echo "<th>Header 2</th>";
      echo "<th>Header 3</th>";
      echo "<th>Header 4</th>";
      echo "</tr>";

      //foreach loop is removed because it will return only single object
      echo '<tr><td>'.$post->post_title.'</td><td>'.$post->post_status.'</td><td>'.$post->post_date_gmt.'</td><td>'.$post->ID.'</td></tr>';

      echo '</table>';
  }

}

BTW, if you need to retrieve multiple posts then try get_posts