I have run into a tough one here, I hope someone would help out. I want the public user to define the order of the display of information on the webpage. The user will know the data fields in the mysql database and make a custom output of the fields in the order he or she wants. Here is my php generating xml:
<?php
header("Content-type: text/xml");
include_once("config.php");
parse_str($_POST['data'], $order);
$order = array(firstname,surname,title,booktitle);
$neworder = explode("&", $order);
echo $neworder[1];
$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;
?>
And the xml output
<entries>
<entry>
<firstname>Kimtai</firstname>
<surname>Evans</surname>
<title>
Operational Decision Support: Context-Based Approach and Technological Framework
</title>
<book_title>Operational Support Decision</book_title>
</entry>
</entries>
What i need is this, the user can change the order of output from a html form by putting the order of the fields he wants, so that the final output on the webpage can start with surname and not firstname for example. I hope i have explained my question well. Any help will be appreciated.
jquery ajax code
<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();
});
htmlspecialchars()instead of the series ofstr_replaces