Datensätze im Formular in DB speichern

klausi89

Erfahrenes Mitglied
Hallo ich wollte mal fragen ob mir mal bitte jemand helfen könnte,

ich komme einfach nicht weiter.

Ich habe mir einen kleinen Adminbereich gemacht wo ich unter anderem ein Profil anlegen kann.

nun habe ich folgenden ansatz:

Code:
<?php


include ("header.php");


$sql = "SELECT * FROM config";

$db = mysqli_query( $conn, $sql );
if ( ! $db )
{
  die('Ungültige Abfrage: ' . mysqli_error());
}

$settings = mysqli_fetch_array( $db, MYSQL_ASSOC);
?>


<div class="panel panel-default">
<div class="panel-heading">
  <i class="fa fa-user"></i> Profil Einstellungen
</div>
  <div class="panel-body">
  <hr />

<form action="" method="post">
<div class="form-group">
<label for="vorname">Vorname:</label>
<input type="text" class="form-control" id="vorname" value="<?php echo  $settings['vorname'];  ?>">
</div>

<div class="form-group">
<label for="nachname">Nachname:</label>
<input type="text" class="form-control" id="nachname" value="<?php echo  $settings['nachname'];  ?>">
</div>

<div class="form-group">
<label for="strasse">Strasse:</label>
<input type="text" class="form-control" id="strasse" value="<?php echo  $settings['strasse'];  ?>">
</div>

<div class="form-group">
<label for="nr">Hausnummer:</label>
<input type="text" class="form-control" id="nr" value="<?php echo  $settings['nr'];  ?>">
</div>

<div class="form-group">
<label for="nachname">Postleitzahl:</label>
<input type="text" class="form-control" id="plz" value="<?php echo  $settings['plz'];  ?>">
</div>

<div class="form-group">
<label for="telefon">Telefon:</label>
<input type="text" class="form-control" id="text" value="<?php echo  $settings['telefon'];  ?>">
</div>

<div class="form-group">
<label for="email">Email:</label>
<input type="text" class="form-control" id="email" value="<?php echo  $settings['email'];  ?>">
</div>

<button class="btn btn-primary btn-block" type="submit"><i class="fa fa-floppy-o" aria-hidden="true"></i> Speichern</button>

</form>
</div>  <!-- ende .panel-body -->
</div>  <!-- ende . panel -->




<?php


include ("footer.php");

?>

Die Verbindung steht, Daten werden abgerufen nur leider weiß ich jetzt nicht wirklich wie ich das mit "UPDATE tabelle SET" anstellen soll
Wäre nett wenn mir da mal jemand helfen könnte damit ich das endlich auch verstehe.

Danke schonmal
 
SQL:
UPDATE [tabelle] SET [Feldname] = [wert], [Feldname] = [wert] WHERE [feldname] = [wert];

/* oder */

UPDATE [tabelle] SET [Feldname] = [Feldname] + [wert], [Feldname] = [wert] WHERE [feldname] = [wert];

Hilft dir das?
 
Zurück