这是一个拖放代码,它被单独保存在数据库中。我想让我的用户根据他们的选择来保存他们的仪表板布局。请看下面的图片,如果您有任何建议,请告诉我。提前致谢!
**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>';
}
?>