I have a table book_assign and when a new record has been inserted, I want to update previous entries for the stud_id and set the column 'status' to become 0.
 public function insert() {
    $stud_id = mysql_real_escape_string($this->stud_id);
    $teach_id = mysql_real_escape_string($this->teach_id);
    $book_id = mysql_real_escape_string($this->book_id);
    $status = mysql_real_escape_string($this->status);
    $dates = mysql_real_escape_string($this->dates);
    $rating = mysql_real_escape_string($this->rating);
    $comments = mysql_real_escape_string($this->comments);
    $insert = "Insert into book_assign(stud_id,teach_id, book_id, dates, status, rating, comments)
                values('$stud_id', '$teach_id', '$book_id', '$dates', '1', '$rating', '$comments')";
    $res = mysql_query($insert);
    $last_id = mysql_insert_id();
    return $res;
}
This is my code so far, I believe I may have to use a trigger does that have to be done in phpmyadmin?
What I'm also wondering is can this be done using two different queries within this function, I have tried but it doesn't seem to work.
 
     
    