在mysql中从5个表中插入2个表

How to insert part of column in MySQL using php ? For example,my column table in sql are : code,Title,Cr,prerequisite,Addit,Grade I used table to fetch the data in php , but Addit and Grade is empty . I want user to insert them the other column is fixed with specific data .

How to insert in just in Addit and Grade ?

The problem i face in this code is that the insert data is coming alone in row not in Addit and Grade with the names of course .

I want from student to define the grade of course name university studies weather A,B,C,D. And ,to define weather students complete or not complete this course.

enter code here
 <html>
 <head>

</head>
  <body>
  <form action="insert.php" name="frmAdd" method="post">

<table border='1' cellpadding='5' cellspacing='1' id='mytable'>
   <tr align='center'>
          <th>code</th>
     <th>Title</th>
     <th>Cr</th>
          <th>prerequisite</th>

                <th>Addi</th>
 <th>grade</th>
   </tr>
   <?php
  error_reporting(0);
      $sql="select code,Title,Cr,prerequisite,Addit,Grade from study_p";
     $result=mysql_query($sql);
       while ($row = mysql_fetch_array($result))`


 $code  = $row['code'];
 $Title = $row['Title'];
      $cr = $row['Cr'];
    $pre = $row['prerequisite'];
    $addit= $row['Addit'];
   $grade = $row['Grade'];


    echo "<tr  class='edit_tr' id='$id'>
      <td class='edit_td'>
        <span class='text' id='one_$ssn' >$code </span>
        <input type='text' class='editbox_search' id='one_input_$ssn'
 value='$code ' >
      </td>

      <td class='edit_td'>
        <span class='text' id='two_$ssn' >$Title</span>
           <input type='text' class='editbox_search' id='two_input_$ssn'      

    value='$Title' >
      </td>

      <td class='edit_td'>
        <span class='text' id='three_$ssn' >$cr</span>
        <input type='text' class='editbox_search' id='three_input_$ssn'
    value='$cr' >
      </td>

      <td class='edit_td'>
        <span class='text' id='three_$ssn' >$pre</span>
        <input type='text' class='editbox_search' id='three_input_$ssn'



      value='$pre' >
      </td>
      <td class='edit_td'>
        <span class='text' id='three_$ssn' >$addit</span>


        <select name='Addit' id='addit'>
         <option value='A'>Completed</option>
        <option value='B'>Not complate</option>

</select>

</td> 
      <td class='edit_td'>
        <span class='text' id='three_$ssn' >$grade</span>

                                <select name='Grade' id='grade'>
        <option value='A'>A</option>
        <option value='B'>B</option>
        <option value='C'>C</option>
        <option value='D'>D</option>
        <option value='F'>F</option>
</select>

</td> 

</tr>";  
 }             
?>

<p><input type="submit" value="Add Link"></p>
</tr>
  </table>
 </div>



insert.php



enter code here
<?php 
$usr = "";
$pwd = "";
$db = "adv";
$host = "localhost";

 $cid = mysql_connect($host,$usr,$pwd);

  if (!$cid) { echo("ERROR: " . mysql_error() . "
"); }
?>

<?php 

if ($_SERVER['REQUEST_METHOD'] == "POST") { 



$addit= $_POST['Addit'];
$grade = $_POST['Grade'];


$sql = " INSERT INTO study_p";
$sql = $sql . " (code,Title,Cr,prerequisite,Addit,Grade) VALUES ";
$sql = $sql . " ('','','','','$addit', '$grade') ";
    $result = mysql_db_query($db,"$sql",$cid);

 if (!$result) { 
 echo("ERROR: " . mysql_error() . "
$sql
");   }

echo ("New Link Added
");

 } 


  mysql_close($cid); 
   ?>

sql

enter code here

  CREATE TABLE IF NOT EXISTS `study_p` (
   `Study_pID` int(25) NOT NULL,
  `code` varchar(25) DEFAULT NULL,
  `Title` varchar(100) DEFAULT NULL,
  `Cr` int(200) DEFAULT NULL,
   `prerequisite` varchar(25) DEFAULT NULL,
   `Addit` varchar(25) DEFAULT NULL,
  `Grade` varchar(100) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;



    insert into studyplancourses values(2, 'UNS 100', 'University Study
    Skills', 3, 'No Prerequisite', NULL, ''),
   insert into studyplancourses values(3, 'ENG 100', 'English I', 3, 'ELI 
     Exit 
   Test or TOEFL 50', NULL, ''),

You are using the wrong sql command. INSERT command will insert a new record into a table. What you want is to UPDATE an existing record. You need to use the UPDATE command to accomplish this.

You need to use the WHERE clause in the update statement to tell mysql which row(s) you would like to update.

Sample sql code:

UPDATE study_p --which table to update
SET addit='...', grade='...' --which fields to update
WHERE code='...' --which record to update

Pls note, that I assumed that the code field uniquely identifies a record. If this is not the case, then you need to use a different where criteria based on your data.