I wonder why my jquery UI does not create an array that i can parse to php, this is my list
<ul id="sortable">
<li id="firstname" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>firstname</li>
<li id="lastname" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>lastname</li>
<li id="title" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>title</li>
<li id="book_title" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>book_title</li>
</ul>
And here is jQuery
<script>
$(function() {
$( "#sortable" ).sortable({
placeholder: "ui-state-highlight",
opacity: 0.6,
update: function(event, ui) {
var info = $(this).sortable("serialize");
alert(info);
$.ajax({
type: "POST",
url: "home.php",
data: info,
context: document.body,
success: function(){
}
});
}
});
$( "#sortable" ).disableSelection();
});
</script>
thi is the result that alert (info ) gives
book[]=title
I want to be able to post the array to php so that the user can change the order of the output according to how he changes it in the list. Someone help
edited from here, my home.php file
<?php
header("Content-type: text/xml");
include_once("config.php");
parse_str($_POST['data'], $order);
echo $order;
$query = "SELECT `author`.`surname`,`author`.`firstname`,`publication`.`title`,`book`.`book_title` FROM author, book, publication ";
$resultID = mysql_query($query, $conn) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<entries>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<entry>\n";
foreach($order as $col){
$xml_output = "\t\t<$col>" . $row[$col] . "</$col\n";
}
$xml_output .= "\t</entry>\n";
}
$xml_output .= "</entries>";
echo $xml_output;
?>