This repository has been archived on 2026-06-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
sgd/ysqld/ysql07d/kap1/1_8_prepare_benannte_platzhalter.php

30 lines
720 B
PHP

<?php
include("list.php");
try {
$pdo = new PDO("mysql:dbname=$dbname;dbhost=$dbhost;charset=utf8", $dbuser, $dbpw);
} catch (PDOException $e) {
die($e->getMessage());
}
$tnummer = 5;
$sql = "SELECT * FROM teilnehmer WHERE tnummer= :tnummer";
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
if ($stmt = $pdo->prepare($sql)) {
$stmt->bindParam(':tnummer',$tnummer);
$stmt->execute();
while ($zeile = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "Teilnehmernummer: " .$zeile ['tnummer'] . "<br>";
echo "Name: " .$zeile ['name'] . "<br>";
echo "Vorname " .$zeile ['vname'] . "<br>";
echo "Ort: " .$zeile ['ort'] . "<br>";
}
}
?>