title: how to insert and delete row data same time
body: <p>hi this is my code for insert data into a database table and i want to delete data from one table and insert data in another table </p>
  
  <pre><code>&lt;form action="page1.php" method="POST"&gt;
  &lt;input type="checkbox" name="chk1" value="one" /&gt; &lt;br/&gt;
  
  &lt;input type="submit" name="submit" value="submit"/&gt;
  &lt;/form&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php
  include 'config.php';
  session_start();
  $user=$_SESSION['sess_user'];
  $checkbox1=$_POST['chk1'];
  if ($_POST["submit"]=="submit")
  {
  
  $result = mysql_query("SELECT std_id,course_name,stdname FROM course_entry WHERE course_id = '".$checkbox1."' and username= '".$user."'");
  if (!$result) {
      echo 'Could not run query: ' . mysql_error();
      exit;
  }
  $row = mysql_fetch_row($result);
  
  echo $row[0]; echo $row[1]; 
  echo $row[2];
  
  $query= "INSERT INTO course_finish (course_id,course_name,username,finishdate) values ('".$row[0]."','".$row[1]."','".$row[3]."',now())"; 
   "delete from course_entry where (course_id,username) values ('".$checkbox1."','".$user."'";
  mysql_query($query) or die (mysql_error());
  
  
  echo "Record is inserted";
  header("Location: profile.php");    
  
  }
  ?&gt;
  </code></pre>
  
  <p>in database insert into course _finish is success full but in course_entry table the row isn't delete</p>