title: How to add category id to another table on selection of category?
body: <p>I have two tables ( post , category )</p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE post    
  (pid INT(10) NOT NULL AUTO_INCREMENT,    
  post_title VARCHAR(255),   
  post_result VARCHAR(255),  
  post_content VARCHAR(500), 
  cid INT(10), 
  PRIMARY KEY (pid),
  FOREIGN KEY (cid) REFERENCES category(cid));   
  
  CREATE TABLE category (  
  cid INT(10) NOT NULL AUTO_INCREMENT,  
  cname VARCHAR(50),  
  PRIMARY KEY (cid));  
  </code></pre>
  
  <p>This is my insert statement:    </p>
  
  <pre><code>$id = isset($_POST['pid'])?$_POST['pid']:'';
  $title=$_POST['post_title'];
  $result=$_POST['post_result'];
  $content=$_POST['post_content'];
  $catid=$_POST['cid'];
  $cat=$_POST['cname'];
  $insertquery="INSERT INTO review (pid,post_title,post_result,post_content)
  VALUES('','$title','$result','$content')";
  </code></pre>
  
  <p>Problem what im facing is, in my post table, the values of category id ( cid ) are NULL for every record.<br>
  How do make it to store the value of selected category. </p>
  
  <p>This is my form:    </p>
  
  <pre><code>&lt;form id="create" action="insert.php" method="post"&gt;
  &lt;input type="text" name="post_title" placeholder="Title" /&gt;&lt;br&gt; 
  &lt;input type="text" name="post_result" placeholder="Final comment" /&gt;&lt;br&gt;
  &lt;textarea name="post_content" placeholder="Review" &gt;&lt;/textarea&gt;&lt;br&gt;
  
      Category:
      &lt;select name=cname&gt;
      &lt;option value="select"&gt;&lt;/option&gt;
      &lt;option value="1"&gt;Option 1&lt;/option&gt;
      &lt;option value="2"&gt;Option 2&lt;/option&gt;
      &lt;option value="3"&gt;Option 3&lt;/option&gt;
      &lt;option value="4"&gt;Option 4&lt;/option&gt;
      &lt;option value="5"&gt;Option 5&lt;/option&gt;
          &lt;/select&gt;&lt;br&gt;&lt;br&gt;
  
  &lt;input class="submit" name="submit" type="submit" value="Submit"/&gt;
  
  &lt;/form&gt;    
  </code></pre>
  
  <p>Do help in getting the output .</p>