pdo update code example

Example 1: update pdo mysql php

$sql = "UPDATE users SET name=?, surname=?, sex=? WHERE id=?";$stmt= $pdo->prepare($sql);$stmt->execute([$name, $surname, $sex, $id]);

Example 2: update pdo mysql php

$sql = "UPDATE users SET name=?, surname=?, sex=? WHERE id=?";$pdo->prepare($sql)->execute([$name, $surname, $sex, $id]);

Example 3: update php sql

$_old_username = "Randy";
$_new_username = $_POST["username"]; 

$_sql = "UPDATE user SET first_name = $_new_username WHERE first_name = $_old_username";

Tags:

Sql Example