I would like to be able to modify a MySQL query based on the selection in a dropdown menu. This would then update the subsequent table shown on the page.
The current code I have is below (note I'm using PHP code snippets (Insert PHP) plugin) however this doesn't have the desired result as no table is generated.
Any assistance would be greatly appreciated.
<form method="POST">
<select name="post_ID">
<option value="21">21</option>
<option value="22">22</option>
</select>
</form>
[insert_php]
global $wpdb;
echo $_POST['post_ID'];
$myQuery = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix.'posts' . 'WHERE ID = $_POST['post_ID']');
if($myQuery){
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 ( $myQuery as $result )
{
echo '<tr><td>'.$result->post_title.'</td><td>'.$result->post_status.'</td><td>'.$result->post_date_gmt.'</td><td>'.$result->ID.'</td></tr>';
}
echo '</table>';
}
[/insert_php]
<input type="submit" name="submit" value="Get Selected Values" />
but still not having much luck