<?php
    include 'dbconnect.php';
    $profession = $_POST['profession'];
    $description = $_POST['description'];
    $userid = $_POST['userid'];
    tryUpdateUserDetails($db, $profession, $description, $userid);
   
function tryUpdateUserDetails($db, $profession, $description, $userid)
{
    $stmt = pg_prepare($db, "update_user_details", 'UPDATE users SET profession = $1, description = $2 WHERE id = $3');
    $result = pg_execute($db, "update_user_details", array($profession, $description, $userid));
    $affectedRows = pg_affected_rows($result);
    
    if ($affectedRows > 0) {
        $response = array('success' => true, 'message' => 'Successfully updated details');
    } else {
        $response = array('success' => false);
    }
      echo json_encode($response);
}
?>
