變數引入方法
$sql="INSERT INTO users (name, sname, sex) VALUES value (?,?,?,?)";
$stmt=$conn->prepare($sql);
$stmt->execute([$name,$sname,$sex]);
陣列方式
$data2=['s044','李金生',21,'女'];
$sql="INSERT INTO student(sno, sname, sage, ssex) VALUES (?,?,?,?) ";
$stmt=$conn->prepare($sql);
$stmt->execute($data2);
OR=============================
$data = [
'name' => $name,
'sname' => $sname,
'sex' => $sex,
];
$sql = "INSERT INTO users (name, sname, sex) VALUES (:name, :sname, :sex)";
$stmt= $pdo->prepare($sql);
$stmt->execute($data);
OR =======================
$data = [
'name' => $name,
'sname' => $sname,
'sex' => $sex,
];
$sql = "INSERT INTO users (name, sname, sex) VALUES (:name, :sname, :sex)";
$pdo->prepare($sql)->execute($data);
=========
https://phpdelusions.net/pdo_examples/update