Wenn ich Speichern klicke, dann wird nichts geändert.
Bestimmt liegt das an INSERT INTO, da ich einfach WHERE hinzugefügt habe. Denn ich will ein Eintrag in der id Liste ändern.
konfiguration.php
PHP-Quellcode
- <?php
- // Zum Aufbau der Verbindung zur Datenbank
- define ( 'MYSQL_HOST', 'localhost' );
- define ( 'MYSQL_BENUTZER', '' );
- define ( 'MYSQL_KENNWORT', '' );
- define ( 'MYSQL_DATENBANK', 'usr_web72_1' );
- //-----------------------------------------
- // Eintrag für Tabelle
- $Tabelle = "Angriffsliste";
- // Eintrag für Spalte
- $SpalteName = "Name";
- $SpalteLvl = "Lvl";
- $SpalteHBgruen = "HB Grün";
- $SpalteHBeis = "HB Eis";
- $SpalteHBsand = "HB Sand";
- $SpalteHBfeuer = "HB Feuer";
- ?>
show.php
PHP-Quellcode
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Unbenanntes Dokument</title>
- </head>
- <body>
- <?php
- include ('konfiguration.php');
- $id = $_GET['id'];
- $db_link = mysqli_connect (MYSQL_HOST,
- MYSQL_BENUTZER,
- MYSQL_KENNWORT,
- MYSQL_DATENBANK);
- if ( ! $db_link )
- {
- die('Ungültige Abfrage: ' . mysqli_error());
- }
- $sql = " SELECT * FROM $Tabelle WHERE id='$id' ";
- $erg = mysqli_query($db_link, $sql);
- $ausgabe = mysqli_fetch_assoc($erg);
- echo '<form name="" action="" method="GET" >';
- echo '<table width="100%" border="1">';
- echo '<tr>';
- echo '<th width="16%" scope="col">Name</th>';
- echo '<th width="16%" scope="col">Lvl</th>';
- echo '<th width="16%" scope="col">HB Grün</th>';
- echo '<th width="16%" scope="col">HB Eis</th>';
- echo '<th width="16%" scope="col">HB Sand</th>';
- echo '<th width="16%" scope="col">HB Feuer</th>';
- echo '</tr>';
- echo '<tr>';
- echo '<td><input type="text" name="Name" value="'.$ausgabe[$SpalteName].'" width="100%" /></td>';
- echo '<td><input type="text" name="Lvl" value="'.$ausgabe[$SpalteLvl].'" width="100%" /></td>';
- echo '<td><input type="text" name="HBe" value="'.$ausgabe[$SpalteHBgruen].'" width="100%" /></td>';
- echo '<td><input type="text" name="HBg" value="'.$ausgabe[$SpalteHBeis].'" width="100%" /></td>';
- echo '<td><input type="text" name="HBs" value="'.$ausgabe[$SpalteHBsand].'" width="100%" /></td>';
- echo '<td><input type="text" name="HBf" value="'.$ausgabe[$SpalteHBfeuer].'" width="100%" /></td>';
- echo '</tr>';
- echo '</table>';
- echo '</p>';
- echo '<p>Notiz:<br />';
- echo '<textarea name="Notiz" rows="10" cols="50">'.$ausgabe['Notiz'].'</textarea>';
- echo '</p>';
- echo '<input type="hidden" name="aktion" value="speichern" />';
- echo '<input type="Submit" value="speichern" />';
- echo '</form>';
- if ( $_GET['aktion'] == "speichern" )
- {
- $name = $_GET['Name'];
- $lvl = $_GET['Lvl'];
- $hbg = $_GET['HBg'];
- $hbe = $_GET['HBe'];
- $hbs = $_GET['HBs'];
- $hbf = $_GET['HBf'];
- $notiz = $_GET['Notiz'];
- $sql = "INSERT INTO $Tabelle SET ";
- $sql .= " $SpalteName = '$name', ";
- $sql .= " $SpalteLvl = '$lvl', ";
- $sql .= " $SpalteHBgruen = '$hbg', ";
- $sql .= " $SpalteHBeis = '$hbe', ";
- $sql .= " $SpalteHBsand = '$hbs', ";
- $sql .= " $SpalteHBfeuer = '$hbf', ";
- $sql .= " Notiz = '$notiz', WHERE id='$id' ";
- }
- ?>
- </body>
- </html>
Bilder sind Leider nicht Erlaubt -.- schade... obwohl ich sowas sehr gerne gestalte und Präsentiere ...