← CodePrimer
PHP
Intermediate
Database
PDO prepared UPDATE
How do I update a record with PDO?
Prepared UPDATE by id.
<?php
$stmt = $pdo->prepare('UPDATE students SET name = ? WHERE id = ?');
$stmt->execute([$name, $id]);
Notes
Always include a WHERE clause.
Keywords: update · pdo · prepared
Related
PHP
Embed PHP inside HTML
How do I mix PHP and HTML?
SQL
CREATE DATABASE
How do I create a MySQL database?
PHP
PHP comments
How do I write comments in PHP?
SQL
ALTER TABLE add column
How do I add a column to an existing table?
PHP
PHP variable rules
What are the rules for PHP variables?
SQL
Foreign key relationship
How do I relate posts to users?