title: How to store value from Drop Down List In Database
body: <p>I have created a Dynamic Drop Down list which is populating data from database. Till now its working fine. Now I want to add the selected data from drop down list into my Database. I have tried various possible methods but unable to insert values in my database, following program is not given any error message but it is also not inserting data in my database. Kindly check it.</p>
  
  <pre><code>    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?php 
  
  session_start();
  if(isset($_SESSION['username']))
  {
  
  
      include 'connect.php';
  
              $select_query=          'Select * from category';
              $select_query_run =     mysql_query($select_query);
  
      echo "  
          &lt;form action='insert_product.php' method='POST' &gt;&lt;/br&gt;
  
          Product Name:   &lt;input type='text' name='product_name'  /&gt;&lt;/br&gt;
  
          Price       :   &lt;input type= 'text' name= 'price'  /&gt;&lt;/br&gt;
  
          Description :   &lt;input type='text' name='description'  /&gt;*Seperate by Comma&lt;/br&gt;
  
                          ";
  
  
  
      //  Drop Down Display   
  
  
  
  
              echo "&lt;select name='category'&gt;";
  
  
              while   ($select_query_array=   mysql_fetch_array($select_query_run) )
              {
  
                      echo "&lt;option value='".$select_query_array['category_id']."' &gt;".
                      htmlspecialchars($select_query_array["name"])."&lt;/option&gt;";
  
  
                  }
  
           $selectTag= "&lt;input type='submit' value='Insert'  /&gt;&lt;/select&gt;&lt;/form&gt;";
  
           echo $selectTag;
      //Drop Down End!
  
  
  
  
      if(isset($_POST['product_name']) &amp;&amp; isset($_POST['price']) &amp;&amp; isset($_POST['description'])  )
      {
          echo $product_name  =       $_POST['product_name'];
          echo $price         =       $_POST['price'];
          echo $description   =       $_POST['description'];
          echo $category      =       $_POST['category'];
  
  
  //Problem Area 
  
      $query= "insert into products (name, price, description,  category_id ) 
                  VALUES( '$product_name', $price, '$description', $category )";
  
  
      if($query_run=      mysql_query($query))
      {
  
          echo 'Data Inserted';
  
  
  
          }   
          else
          {
              'Error In SQL'.mysql_error();
              }
      }
  
      else
      {
          echo 'empty Field';
          }
  
  }
  
  else
  {
      echo 'You Must Log in To View this Page!';
      }
  ?&gt;
  </code></pre>