2
0

datenbanken in php, aufgabe a2-a5

This commit is contained in:
Schuledaniel
2025-12-09 14:29:59 +01:00
parent 9b39a80879
commit 688c610a85
4 changed files with 208 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
<?php
// USERNAME, password
//$pdo = new PDO("mysql:host=localhost", "phpmyadmin", "server");
$pdo = new PDO("mysql:host=localhost;dbname=person","phpmyadmin","server");
$createTable= 'CREATE TABLE IF NOT EXISTS schueler(
id INTEGER AUTO_INCREMENT PRIMARY KEY, -- zahl, wird automatisch ausgefüllt
frstName VARCHAR(255) NOT NULL,
lastName VARCHAR(255) NOT NULL
);';
$pdo->exec($createTable);
echo 'TABELLE ERSTELLT <br>';
$createUser ='INSERT INTO schueler VALUES(
null, -- null da "AUTO_INCREMENT" gestzt wurde
"Schüler Vorname",
"Schüler Nachname"
)';
$pdo->exec($createUser);
echo 'NUTZER ERSTELLT <br>';
?>