Reputation: 270
i have new_cats
table it contains id, title, order
and i post data from the table like this
php
<table>
<tbody class="sort">
<?php
$select_newscats = $mysqli->query("SELECT * FROM news_cats order by ord_show asc");
while ($rows_newscats = $select_newscats->fetch_array(MYSQL_ASSOC)){
$id_newscats = $rows_newscats ['id'];
$title_newscats = $rows_newscats ['title'];
$order_newscats = $rows_newscats ['order'];
?>
<tr class="trtable" id="item_<? echo $id_newscats; ?>">
<td><? echo $id; ?></td>
<td><? echo $title_newscats; ?></td>
</tr>
<?
}
?>
<button class="savesort"></button>
</tbody>
</table>
and i have this jquery code to sortable table and trying to update order in database
$(document).ready(function(){
$(".sort").sortable({
update: function (event, ui) {
var order = $(this).sortable('serialize');
}
}).disableSelection();
$('.savesort').on('click', function () {
var aa = $(".sort").sortable("serialize", {
attribute: "id"
});
var s = {
"aa":aa
}
$.ajax({
data: s,
type: 'POST',
url: 'ajax/save_newscats_ord.php',
success:function(data){
alertify.success(data);
}
});
return false;
});
});
in this page save_newscats_ord.php
i tried to save order but i don't get any data from jquery code i tried this code to get data
<?php
$list = $_post['aa'];
echo $list;
?>
how can i send data to php page and how can i save it in my database in order filed
Upvotes: 0
Views: 816
Reputation: 3763
You need to change your PHP code to reference the actual POST variable passed, change this line:
$list = $_post['aa'];
to
$list = $_POST['aa'];
Note that the variable names are case sensitive in PHP.
Upvotes: 1