This is a drag and drop code it's getting saved in the database individually. I want to give my users facility to save their dashboard layout according to their choice. Please look at the following image and if you have any suggestions let me know. Thanks in advance!

![enter image description here](https://i.stack.imgur.com/G9Crk.jpg) 

```
    **index.php**
        <script type="text/javascript">
        $(document).ready(function(){ 

            $(function() {
                $("#contentLeft #db_boxes").sortable({ opacity: 0.6, cursor: 'move', update: function() {
                    var order = $(this).sortable("serialize") + '&action=updateRecordsListings'; 
                    $.post("updateDB.php", order, function(theResponse){
                        $("#contentRight").html(theResponse);
                    });                                                              
                }                                 
                });
            });

        }); 
        </script>

    **updateDB.php**

    <?php 
    require("db.php");
    $username = $_SESSION['username'];

    $action = mysql_real_escape_string($_POST['action']); 
    $updateRecordsArray = $_POST['recordsArray'];

    if ($action == "updateRecordsListings"){

        $listingCounter = 1;
        foreach ($updateRecordsArray as $recordIDValue) {

            $query = "UPDATE dnd_records SET recordListingID = " . $listingCounter . " WHERE username = " . $username;
            mysql_query($query) or die('Error, insert query failed');
            $listingCounter = $listingCounter + 1;  
        }

        echo '<pre>';
        print_r($updateRecordsArray);
        echo '</pre>';

    }
    ?>

```