Voll Upload SGD Fachinformatiker PHP
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
class Dozent {
|
||||
private $tabelle = "dozenten";
|
||||
public function loeschen($id) {
|
||||
require ("db.inc.php");
|
||||
$sql = "DELETE FROM " . $this->tabelle . " WHERE doznr = :doznr";
|
||||
if ($stmt = $pdo->prepare ( $sql )) {
|
||||
$stmt->bindParam ( ':doznr', $id );
|
||||
$stmt->execute ();
|
||||
}
|
||||
}
|
||||
public function anlegen($felder) {
|
||||
require ("db.inc.php");
|
||||
|
||||
$doznr = NULL;
|
||||
$name = $felder ["name"];
|
||||
$vname = $felder ["vname"];
|
||||
$plz = $felder ["plz"];
|
||||
$ort = $felder ["ort"];
|
||||
$strasse = $felder ["strasse"];
|
||||
$hausnr = $felder ["hausnr"];
|
||||
$telefon1 = $felder ["telefon1"];
|
||||
$telefon2 = $felder ["telefon2"];
|
||||
$email = $felder ["email"];
|
||||
$sql = "INSERT INTO " . $this->tabelle . " (doznr,
|
||||
name,
|
||||
vname,
|
||||
plz,
|
||||
ort,
|
||||
strasse,
|
||||
hausnr,
|
||||
telefon1,
|
||||
telefon2,
|
||||
email)
|
||||
VALUES (
|
||||
:doznr,
|
||||
:name,
|
||||
:vname,
|
||||
:plz,
|
||||
:ort,
|
||||
:strasse,
|
||||
:hausnr,
|
||||
:telefon1,
|
||||
:telefon2,
|
||||
:email)";
|
||||
|
||||
if ($stmt = $pdo->prepare ( $sql )) {
|
||||
$param = array (
|
||||
':doznr' => $doznr,
|
||||
':name' => $name,
|
||||
':vname' => $vname,
|
||||
':plz' => $plz,
|
||||
':ort' => $ort,
|
||||
':strasse' => $strasse,
|
||||
':hausnr' => $hausnr,
|
||||
':telefon1' => $telefon1,
|
||||
':telefon2' => $telefon2,
|
||||
':email' => $email
|
||||
);
|
||||
|
||||
if ($stmt->execute ($param)) {
|
||||
echo "<h2>Datensatz erfolgreich gespeichert!</h2>\n";
|
||||
} else {
|
||||
echo "<h2>Fehler beim Speichern!</h2>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
public function bearbeiten($felder) {
|
||||
require ("db.inc.php");
|
||||
|
||||
$doznr = $felder ["mode"];
|
||||
$name = $felder ["name"];
|
||||
$vname = $felder ["vname"];
|
||||
$plz = $felder ["plz"];
|
||||
$ort = $felder ["ort"];
|
||||
$strasse = $felder ["strasse"];
|
||||
$hausnr = $felder ["hausnr"];
|
||||
$telefon1 = $felder ["telefon1"];
|
||||
$telefon2 = $felder ["telefon2"];
|
||||
$email = $felder ["email"];
|
||||
|
||||
$sql = "UPDATE ". $this->tabelle . " SET
|
||||
name = :name,
|
||||
vname = :vname,
|
||||
plz = :plz,
|
||||
ort = :ort,
|
||||
strasse = :strasse,
|
||||
hausnr = :hausnr,
|
||||
telefon1 = :telefon1,
|
||||
telefon2 = :telefon2,
|
||||
email = :email
|
||||
WHERE doznr = :doznr";
|
||||
|
||||
if ($stmt = $pdo->prepare ( $sql )) {
|
||||
$param = array (
|
||||
':doznr' => $doznr,
|
||||
':name' => $name,
|
||||
':vname' => $vname,
|
||||
':plz' => $plz,
|
||||
':ort' => $ort,
|
||||
':strasse' => $strasse,
|
||||
':hausnr' => $hausnr,
|
||||
':telefon1' => $telefon1,
|
||||
':telefon2' => $telefon2,
|
||||
':email' => $email);
|
||||
|
||||
if ($stmt->execute ($param)) {
|
||||
echo "<h2>Datensatz erfolgreich gespeichert!</h2>\n";
|
||||
} else {
|
||||
echo "<h2>Fehler beim Speichern!</h2>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
public function lesenDatensatz($id) {
|
||||
require ("db.inc.php");
|
||||
if ($stmt = $pdo->prepare ( "SELECT name, vname, plz, ort, strasse, hausnr, telefon1, telefon2, email FROM " . $this->tabelle . " WHERE doznr=:doznr" )) {
|
||||
$stmt->bindParam ( ':doznr', $id );
|
||||
$stmt->execute ();
|
||||
return ($stmt ->fetch(PDO::FETCH_ASSOC));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function lesenAlleDaten() {
|
||||
require_once ("db.inc.php");
|
||||
if ($stmt = $pdo->prepare ( "SELECT doznr, name, vname, plz, ort, strasse, hausnr, telefon1, telefon2, email FROM " . $this->tabelle . " ORDER BY name" )) {
|
||||
$stmt->execute ();
|
||||
echo "<table id=\"zebra\">\n\t";
|
||||
echo "<thead><tr><th>Nummer</th><th>Name</th><th>Vorname</th><th>Plz</th><th>Ort</th><th>Straße</th><th>Haus-Nr.</th><th>Telefon 1</th><th>Telefon 2</th><th>E-Mail</th><th>Bearbeiten</th></tr></thead>";
|
||||
echo "<tbody>\n\t";
|
||||
$count = 0;
|
||||
while ( $z = $stmt->fetch () ) {
|
||||
$count += 1;
|
||||
$zebratyp = "ungerade";
|
||||
echo "<tr ";
|
||||
if ($count % 2 == 0) {
|
||||
$zebratyp = "gerade";
|
||||
}
|
||||
echo "class=\"" . $zebratyp . "\">\n\t<td>"
|
||||
. htmlspecialchars ( $z['doznr'])
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['name'])
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['vname'] )
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['plz'])
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['ort'] )
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['strasse'])
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['hausnr'] )
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['telefon1'])
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['telefon2'] )
|
||||
. "</td>\n\t<td>" . htmlspecialchars ( $z['email'] )
|
||||
. "</td>\n\t<td>" . "<a href=\"dbearbeiten.php?doznr=" . htmlspecialchars ( $z['doznr'] ) . "\">bearbeiten</a>" . "</td>\n</tr>";
|
||||
}
|
||||
echo "</tbody>\n</table>\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user