PHP从选择框中获取选定的值?

This is my code for get database data to select box and i wanna get the seleceted value.I tries many ways but im missing something. help me

<form id="search" action="" method="post" >
   <select name="owner" id="owner">
   <?php 
      $sql = mysql_query("SELECT designation FROM designation");
      while ($row = mysql_fetch_array($sql)){
      echo '<option value="'.$row['designation'].'">'.$row['designation'].'</option>';
      }
      ?>
   </select>
   <input type="submit" value="Search">
</form>

As you didn't specify an action for your form, the default will be to send the post values to the same page.

See this for more information about action value.

So, in the same page you have the form, you should add a

if(isset($_POST['owner']))
{
    // Do some stuff
}
else
{
    // Print the form
}

$_POST['owner'] contains the value of select box once you submit the form.And $_POST contains all the value of input elements you submitted via the form.if you print_r($_POST); it will show you all the values submitted through the form.

If you

echo $_POST['owner'];//Will display the value of your selected value in the select box.

First make sure to include the action. Secondly to get a POST request of a select tag all you have to do is the following:

$_POST["owner"];
<form id="search" action="" method="post" >
            <select name="owner" id="owner">
            <?php 
             $owner="rejayi"
            $sql = mysql_query("SELECT designation FROM designation");
            while ($row = mysql_fetch_array($sql)){
               if($row['designation'] ==  $owner){
     echo '<option value="'.$row['designation'].'" selected="selected">'.$row['designation'].'</option>';
               }else{
           echo '<option value="'.$row['designation'].'">'.$row['designation'].'</option>';
               }
            }
            ?>
            </select>
            <input type="submit" value="Search">
            </form>

Put Double quotes (") outside and single quotes (') inside

eg:

echo "<option value='".$row['designation']."'>".$row['designation']."</option>";