删除后,值不会重新插入

时间:2014-10-02 10:45:28

标签: php mysql

我有一个关系db.i需要进行更新并重新插入。但所有这一切都是删除而不是重新更新/插入

if($_POST['value_coming'] !=""){
  $delete_value_query=" DELETE  FROM values WHERE value_id='$value_id' ";
  $result=mysqli_query($connection,$delete_value_query);
  confirm_query($result);    
  foreach($_POST['value_coming'] as $value_coming_id){    
     $value_query="INSERT INTO values(value_id,value_coming_id)
   VALUES($student_id,$value_coming_id) ";  
    if($value_query && mysqli_affected_rows($connection)>0){
         echo "updated sucessully";
    }else{echo " could not update" . mysqli_error($connection);}  
 }//foreach end   
}

1 个答案:

答案 0 :(得分:0)

if(mysqli_query($value_query) && mysqli_affected_rows($connection)>0)