Dropdown list & MySQL Query
-
Hi I’m trying to create a form with a dropdown list where I can select a custom field of search.
It’s embedded in a plugin that I’m developing, I have some values in my database and I want to display the results using a custom field (using a PHP form) from the objects in the database, so I wrote….
This is the PHP form:<form method="get" id="plants" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Kind of plants:<br /> <select name="id_plants"> <option value=""></option> <option value="tree">Trees</option> <option value="shrub">Shrubs</option> <option value="bush">Bushes</option></select> <br /> <input type="submit" value="View"> </form>
And this is the query:
$myplants = $wpdb->get_results("SELECT * FROM plants_table WHERE id_plants = '".$_GET['id_plants']."'");
Unfortunatelly when I press “View” it returns to the homepage.
The PHP Form and the database query are in the same file and in the same function.
Any hints?
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Dropdown list & MySQL Query’ is closed to new replies.