Please note, I have gone through the below StackOverflow question which is exactly what i need but unfortunately, it isn't posting
My Code -
Test.php
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#sortable" ).sortable();
    $( "#sortable" ).disableSelection();
  } );
  </script>
<ul id="sortable">
    <li id="item-1">Item 1</li>
    <li id="item-2">Item 2</li>
</ul>
Span 1: <span id="span"></span>
Span2: <span id="span2"></span>
<script>
$(document).ready(function () {
    $('ul').sortable({
        axis: 'y',
        stop: function (event, ui) {
            var data = $(this).sortable('serialize');
            $('#span2').text(data);
            $.ajax({
                data: data,
                type: 'POST',
                url: 'test2.php',
                success: function(data){ 
                    $("#span").text(data); 
                }
            });
    }
    });
});
</script>
Test2.php
<?php 
 include('../db.php'); 
$date = $_POST["data"];
$conn = new mysqli ($servername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE table SET something = '$something'
            WHERE id = '$id'";
    
    if(mysqli_query($conn, $sql)){
        
        echo $date;
    }
    
$conn->close();
?>
Can anyone help me out why the data is not posting to test2.php page
and
how can i sort the table using the data posted to test2.php
Thanks in advance.
