'How Can i save jquery sortable connected lists in database mysql?

Hey guys I have two connected lists and I don't know how to pass or get values correctly

I have Two list

The left list: the value I want to add is "0" which mean it's inactive

The Right list: the value that I want to add is "1" which mean it's active also with a value position

Image for more details

this is my HTML code:

<h5>inactive fruit</h5>
<ul id="sortable1" class="connectedSortable">

        <?php foreach($rows as $row){
                        if($row['active'] === '0'){ ?> 
        
            <li class="ui-state-default"><?php echo $row['name']?></li>
        
        <?php   }}?>
</ul>


<h5>Active Market</h5>
<ul id="sortable2" class="connectedSortable">

    <?php foreach($rows as $row){
                        if($row['active'] === '1'){ ?> 
        
            <li class="ui-state-default"><?php echo $row['name']?></li>
        
        <?php   }}?>
</ul>

This is js code:

  <script>
   $( function() {
    $( "#sortable1, #sortable2" ).sortable({
      connectWith: ".connectedSortable",
        }).disableSelection();
   } );
  </script>

i want to do it with ajax

The Database structure is:

ID (int),

name (varchar),

active (varchar) number 1 means active number 2 means inactive,

posistion(varchar) for the posistion rank



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source