Reputation: 537
I am trying to get the option selected by the user by using PHP (failing in that) where the dropdown itself contains the names of the tables and has been generated using PHP. This is my code for dropdown and grabbing its value:
Edited version of the code:
if(isset($_POST["submit"]))
{
//This code is to show all the tables in database ecommerce having word "brand" in it
$query = "SHOW TABLES FROM ecommerce LIKE '%_brand'";
$runQuery = mysql_query($query);
echo "<form method='post' action='#'>";
echo "<select name='mee'>";
while($row = mysql_fetch_array($runQuery))
echo "<option value='something'>".$row[0]."</option>";
echo "</select>";
echo "</form>";
$var = $_POST["mee"];
echo $var;
}
this is the error:
Undefined index: mee in C:\......
Upvotes: 1
Views: 608
Reputation: 163
Add values to options. You're adding values from database to options in that way that user can see the value when selecting. But you don't set value of each option, so when you send selected option it will use value of option and send it with post method.
echo "<option value='".$row[0]."'>something that user see</option>"
Upvotes: 1
Reputation: 1023
Try this for the option tag.
<option value="something ">.$row[0].</option>
Maybe you are missing option value
Upvotes: 1