I have a piece of code in which I can select a user from the database.
<html>
<form method="post">
Vak:<select name="gebruiker">
<?php
$resultaat = mysqli_query($mysql,"SELECT * FROM gebruikers ORDER BY gebruikersnaam") or die("De query op de database is mislukt!");
while ($rij = mysqli_fetch_assoc($resultaat)){
echo "<option value=\"{$rij['id']}\">{$rij['gebruikersnaam']} {$rij['voorletters']} {$rij['achternaam']} {$rij['rol']} {$rij['actief']} {$rij['vak']}</option>";
}
?>
</select><br>
</form>
</html>
Now I want to save the ID of the selected user into the variable '$id', but only the ID. I want to use this variable in the following query (at WHERE).
<?php
mysqli_query($mysql,"UPDATE gebruikers SET gebruikersnaam =
'$gebruikersnaam', wachtwoord ='$wachtwoord',voorletters ='$voorletters',
achternaam ='$achternaam', rol='$rol',actief='$actief',vak='$vak' WHERE
id = '$id'")
or die("De updatequery op de database is mislukt!");
?>
I know I can save all the data from the selected user with
<?php
$gebruiker = mysqli_real_escape_string($mysql,$_POST['gebruiker']);
?>
but I only need the ID from the user. Does someone know how I can do this?
Thanks in advance