This is what my database table looks like:
id | role | adviser
1 | section |
2 | teacher |
I want to insert a new section and update the existing teacher with the adviser column. Is this possible?
with pdo,while you have connected successfully
require_once 'includes/db_connect.php';
And as you have get the values with select and assigned them to variables $sectionfromadviser and $teacherfromadviser you can procedure like this
try{
//update the verify column from users
$sql="UPDATE tablename SET section=:section,teacher=:teacher WHERE id = :id";
$stmt= $db->prepare($sql);
$stmt->bindParam(':section', $sectionfromadviser);
$stmt->bindParam(':teacher', $teacherfromadviser);
$stmt->bindParam(':id', $id);
$stmt->execute();
}catch(PDOException $e){
if(!$stmt->execute()){
throw $e;
}
}catch (Exception $e) {
throw $e;
}