Trying to make a CRUD, everything works except my Update function. I feel like the problem is in the second sql query. When I click on submit it just refreshes and the change is gone. Can anyone show me how to find what I need to change/show me what to change?
    <head>
<title>Update</title>
</head>
<body>
</form>
<?php 
require_once('dbconnect.php');
$id =  $_GET['id'];
$sql = "SELECT * FROM dealers where ID=$id";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo '<form action="" method="post">';
        echo "Company: <input type=\"text\" name=\"CName\" value=\"".$row['CName']."\"></input>";
        echo "<br>";
        echo "Contact: <input type=\"text\" name=\"Contact\" value=\"".$row['Contact']."\"></input>";
        echo "<br>";
        echo "City: <input type=\"text\" name=\"City\" value=\"".$row['City']."\"></input>"; 
        echo "<br>";
        echo "<input type=\"Submit\" = \"Submit\" type = \"Submit\" id = \"Submit\" value = \"Submit\">";
        echo "</form>";
    }
    echo "</table>";
} else {
    echo "0 results";
}
if(isset($_POST['Submit'])){
$sql = "UPDATE dealers SET CName='$CName', Contact='$Contact', City='$City' where ID=$id";
$result = $conn->query($sql);
}
$conn->close();
?>
 
     
    