pdo statements
Hauptmenü-edit
hmenu.php
Sprung variable setzen
if($jumpi=='recht')
{
Post
echo'<form method="post" action="index.php?page=99&jump=2&jumpi=recht&mem_id='.$mem_id.'">';
echo'<table class="tables faces">';
echo'<tr>';
echo'<th colspan="2">Haupt-Menü Edit</th>';
echo'</tr>';
Datenbank abfrage
$stmt = $pdo->prepare("SELECT id,label,ziel,link_url,parent_id FROM test_menu WHERE id=:id");
$stmt->bindParam(':id',$mem_id,PDO::PARAM_INT);
$stmt->bindColumn(1,$mem_id);
$stmt->bindColumn(2,$m_label);
$stmt->bindColumn(3,$m_ziel);
$stmt->bindColumn(4,$m_link);
$stmt->bindColumn(5,$m_parid);
$stmt->execute();
Daten ausgabe
while($stmt->fetch())
{
echo'<tr>';
echo'<td>ID:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="id" value="'.$mem_id.'">';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>Menüname:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="label" value="'.$m_label.'">';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td >wohin:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="linkurl" value="'.$m_link.'">';
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>PaarID:</td>';
echo'<td>';
echo'<input class="form-controle" type="text" name="parentid" value="'.$m_parid.'">';
echo'</td>';
echo'</tr>';
}
echo'<td>';
echo'<input class="butli button-blue" type="submit" name="labelneu" value="Speichern">';
echo'</td>';
echo'<td>';
echo'<button class="butli" type="submit" formaction="index.php?page=99&jump=2&jumpi=show">zurück</button>';
echo'</td>';
echo '</table>';
echo'</form>';
Sprungmarke setzen
if(isset($_POST['labelneu']))
{
$id = $mem_id;
Post Daten
$label = isset($_POST['label']) ? $_POST['label'] : '';
$linkurl = isset($_POST['linkurl']) ? $_POST['linkurl'] : '';
$parent = isset($_POST['parentid']) ? $_POST['parentid'] : '';
Datenbank aktualisieren
$stmt = $pdo->prepare('UPDATE test_menu SET label=:label,ziel=:ziel,link_url=:linkurl,parent_id=:parentid WHERE id=:id');
$stmt->bindParam(':id',$id,PDO::PARAM_INT);
$stmt->bindParam(':label',$label,PDO::PARAM_STR);
$stmt->bindParam(':ziel',$id,PDO::PARAM_INT);
$stmt->bindParam(':linkurl',$linkurl,PDO::PARAM_STR);
$stmt->bindParam(':parentid',$parent,PDO::PARAM_INT);
if($stmt->execute())
{
header("Location:index.php?page=99&jump=2&jumpi=show");
}
else
{
echo"Da ist was schief gelaufen";
}
Sprung variablen ende
}
}
Top
Top