For some reason it won't update, instead it will add the new data. I am a beginner, and I have hard time trying to find out the error.
Read function was working very properly and insert works just fine as well. Its just the update that doesn't work properly or inserts instead of updating the query or data.
<?php include "db.php"; ?>
<?php include "functions.php" ?>
<?php
if(isset($_POST['submit']))
{$username = $_POST['username'];
$password = $_POST['password'];
$id = $_POST['id'];
$querys = "UPDATE users SET ";
$querys .= "username = '$username', ";
$querys .= "password = '$password' ";
$querys .= "WHERE id = $id ";
$result = mysqli_query($connection, $querys);
if(!$result)
{
die('Query FAILED'. mysqli_error($connection));
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css
">
</head>
<body>
<div class="container">
<div class="col-xs-6">
<form action="login_create.php" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" name="username" class="form-control">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" class="form-control">
</div>
<div class="form-group">
<select name="id" id="">
<?php
showAllData();
?>
</select>
</div>
<input class="btn btn-primary"
type="submit" name="submit" value="Update">
</form>
</div>
</div>
</body>
</html>
Thank you for the help.