I'm really stuck at this point.
What I'm trying to do is that I generate a table with information from my database.
And behind every information there is a button to change the saved data.
The name of my button is the ID of the current data.
<form method='POST'>
<button type='button' name='".$zeile['ID']."' onclick='edit()'>EDIT BUTTON</button>
</form>
So, if I click on the button my div form shows up which looks like this:
<div id="edit" onclick="off()">
<form class="newmitarbeiter" method="POST">
<label>EDIT THIS DATA</label>
<label>Name: </label>
<input type="text" name="nachname" value="<?php echo $firstname ?>"></input>
<label>Vorname: </label>
<input type="text" name="vorname" value="<?php echo $lastname; ?>"></input>
<label>Abteilung: </label>
<input type="text" name="abteilung" value="<?php echo $section; ?>"></input>
<label>Stockwerk: </label>
<input type="text" name="stockwerk" value="<?php echo $floor; ?>"></input>
<br/><br/>
<input name="hinzufuegen" type="submit" value="Abspeichern" class="hinzufuegen" ></input>
<input name="abbrechen" type="submit" value="Abbrechen" class="abbrechen" ></input>
</form>
</div>
I want that the value of the data is already in the form. And to know which EDIT button I've clicked I run a loop which checks if the clicked button's name is a specific number.
for($i = 1; $i < 100; $i++){
if(isset($_POST[$i])){
SQL query which defines my variables in the form above
}
}
My problem now is, that I get an error message that my variables in the form are not defined. I guess that the if statement never gets true but I don't even know why.
I'd be really thankful if anyone can help me.
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire