I want to have a input that can change the value of a row in my database. (mysqli) For example:
if option 1 is selected, the row will change in the value of option 1. And if option 2 is selected, the row will change in the value of option 2. How do i do that? My code of the inc. file:
if(isset($_POST['adjust-groep'])) {
$sqlGroep = 'UPDATE employee set groep=? WHERE ID=?';
$stmtGroep = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmtGroep, $sqlGroep)) {
echo 'MYSQLI statement mislukt';
} else {
mysqli_stmt_bind_param($stmtGroep, "si", $newGroep, $id);
mysqli_stmt_execute($stmtGroep);
$resultGroep = mysqli_stmt_get_result($stmtGroep);
if(!$resultGroep) {
header('Location: ../control.php?error=success');
exit();
} else {
header('Location: ../control.php?error=fail');
exit();
}
}
}
The other code of the select:
<form action="includes/controladjust.inc.php" class="form-group>
<select name="adjust-Groep" class="custom-select" id="inputGroupSelect01">
<option selected>Huidige groep: <?php echo $Groep ?></option>
<option name="Admin" value="2">Admin</option>
<option name="user" value="3">user</option>
</select>
<button type="submit" name="adjust-groep" class="mt-2 btn btn-success">groep wijzigen</button>
</form>
With kind regards,
mysqli_stmt_get_result()There is no result set from an UPDATE. Just a TRU or FALSE to tell you it worked or failed.$resultGroep = mysqli_stmt_execute($stmtGroep);will give you a boolean to test