I want to update my form using PHP and SQL but update query not working. select query working but update not working. there is no error. when I am using a select query for show value in the input field and it's working. I am trying much think but not figure out what is the error. I am trying much think but not figure out what is the error.
<?php
    include 'connection.php';
    include 'config.php';
    if (isset($_GET['edit'])) {
    {
        $topHeading=$_POST['topHeading'];
        $mainHeading=$_POST['mainHeading'];
        $bottomHeading=$_POST['bottomHeading'];
          $filesname = $_FILES['file']['name'];
      $target_dir = "uploads/";
      $target_file = $target_dir . basename($_FILES["file"]["name"]);
      // Select file type
      $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
      // Valid file extensions
      $extensions_arr = array("jpg","jpeg","png","gif","svg");
      // Check extension
      if( in_array($imageFileType,$extensions_arr) ){
        // Convert to base64 
        $image_base64 = base64_encode(file_get_contents($_FILES['file']['tmp_name']) );
        $images = 'data:image/'.$imageFileType.';base64,'.$image_base64;
        $sql = "update banner set topHeading='$topHeading', filesname='$filesname', images='$images', mainHeading='$mainHeading', bottomHeading='$bottomHeading' where id='$id'";
    if (mysqli_query($connection, $sql)) {
        echo "Done";
    } else {
        echo "Error: " . $sql . "<br>" . mysqli_error($connection);
    }
    // mysqli_close($connection);
            // Upload file
        move_uploaded_file($_FILES['file']['tmp_name'],$target_dir.$filesname);
        if($sql)
        {
            echo "";
        }
        else
        {
            echo "<script>alert('Data not inserted');</script>";
        }
    }
    }
    }
    $query = mysqli_query($connection, "select * from banner");
    while ($row = mysqli_fetch_array($query)) {
    echo "<b><a href='editbanner.php?id={$row['id']}'>{$row['topHeading']}</a></b>";
    echo "<br />";
    }
    if (isset($_GET['edit'])) {
    echo '<div class="form" id="form3"><br><br><br><br><br><br>
    <Span>Data Updated Successfuly......!!</span></div>';
    }
    ?>
    <?php
    if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $count = 0;
    $mysqli = mysqli_query($connection,"SELECT * FROM banner");
    foreach($mysqli as $row){
     $count++;
    ?>
    <form class="form-horizontal" method="post" name="form1" id="form1"  enctype="multipart/form-data">
    <div class="form-group label-floating form-rose">
    <label for="brandname" class="control-label col-xs-2">Brand Name of Stock Broker</label> 
    <div class="col-xs-12"> 
    <input type="text"  name="topHeading" id="brandname" class="form-control" value="<?php echo $row["topHeading"]; ?>"/> 
    <span class="error" id="pointfn"></span>
    </div>
    </div>
    <div class="form-group label-floating form-rose">
    <label for="name" class="control-label col-xs-2">Contact Person</label> 
    <div class="col-xs-12"> 
    <input type="text" name="mainHeading" id="name" class="form-control"  value="<?php echo $row["mainHeading"]; ?>"/> 
    <span class="error" id="pointln"></span>
    </div>
    </div>
    <div class="form-group label-floating form-rose">
    <label for="designation" class="control-label col-xs-2">Designation</label> 
    <div class="col-xs-12"> 
    <input type="text" name="bottomHeading" id="designation" class="form-control"  value="<?php echo $row["bottomHeading"]; ?>"/> 
    <span class="error" id="designationln"></span>
    </div>
    </div>
    <div class="label-floating form-rose file-upload">
      <div class="file-select">
        <div class="file-select-button" id="fileName">Upload Logo</div>
        <div class="file-select-name" id="noFile">No file chosen...</div> 
        <input type="file" name="file" id="chooseFile" required>
      </div>
    </div>
    <div class="form-group label-floating form-rose">
    <div class="col-xs-12"> <input type='checkbox' name='checkbox' id="checkbox" required /> <label for="checkbox" class="col-xs-10 term">I accept  <a href="Execution-Partner-T&C.pdf" target="blank"> the terms and condition</a></label>
    </div>
    </div>
    <button  type="submit" name="edit" value="Submit" id="formT" class="button-cta cta btn" onClick="return validateForm()"> I am Interested!</button>
    </form> 
    <?php }} ?>
    </body>
    </html>
 
    