I have a mysql database that has previously stored the text of an xml file including tags. I want to select that data from the database and return it as an xml file rather than just text, (eg filename.xml). It is to be further processed with a javascript file which will output as HTML. I'm no xml programmer but have been trying a couple of things and have included my most recent attempt below for constructive comment.
The file check.php selects the xml data from the database, but the display does not show any xml tags. They are there though because a view source will show them. I am expecting that if the data is selected and saved into a temporary Result.xml, the header towards the end of check.php will call the javascript file to act on the Result.xml. That's the plan, anyway.
check.php
<?php
if (isset($_SESSION['id'])) {
include_once("../../real_conn/real_i_conn.php");
$id = $_SESSION['id'];
$userId = $_SESSION['userId'];
$userIdRec = $id;
$managerId = $_SESSION['managerId'];
$userIdRec = $_SESSION['userIdRec'];
$quizTitle = "";
$quizTitle = mysqli_real_escape_string($conni, $_GET['quizTitle']);
}
else
{
?>
<html>
<table>
<td>You must be logged in through the<br />
<a href="../../index.php">Student Portal</a><br />
to be able to check your quiz results.</td>
</table>
</html>
<?php
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Quiz Result Management Panel</title>
</head>
<?php
//header("Content-type: text/xml");
$sql = "SELECT Result FROM safetyte_stol.quiz WHERE managerId = '$managerId' AND userIdRec = '$userIdRec' AND quizTitle = '$quizTitle'";
$result = mysqli_query($conni, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$Result = $row["Result"];
//$Result=simplexml_load_string($row["Result"]);
//header("Content-Type: application/xml");
print_r($Result);
}
} else {
echo "0 results";
}
?>
<table>
<tr>
<td>
<?php echo $userId. ". Here are the results of your most recent ".$quizTitle." Quiz";?><br /></td>
</tr>
<tr>
<td ><?php //header("location: safetytesting.php");?> <br /></td>
</tr>
<tr>
<td> <br /> <br /></td>
</tr>
</table>
</center>
</div>
</body>
</html>
The resultant display produced by the above script begins as follows. I haven't included much of the file because it is too long and generally illelevant, however I suspect the first lines are determining that the file is other than xml.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Quiz Result Management Panel</title>
</head>
<body onBlur="this.focus()" topmargin="18">
<center>
<quizReport xmlns="http://www.ispringsolutions.com/ispring/quizbuilder/quizresults" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ispringsolutions.com/ispring/quizbuilder/quizresults quizReport.xsd" version="1"><quizSettings quizType="graded" maxScore="14" maxNormalizedScore="100" timeLimit="0"><passingPercent>1</passingPercent></quizSettings><summary score="12" percent="0.857" time="96"><variables/></summary><questions><trueFalseQuestion id="{5B4DDC46-32A2-4999-A016-FD259B65885B}" status="correct" maxPoints="1" maxAttempts="0" awardedPoints="1" usedAttempts="1"><direction>Choose whether 1+1=2 is true or false.
</direction><answers correctAnswerIndex="0" userAnswerIndex="0"><answer>True
</answer><answer>False
</answer></answers></trueFalseQuestion><trueFalseQuestion id="{9EC057E6-6DFE-44DA-9F94-3A2CA492A82F}" status="correct" maxPoints="1" maxAttempts="0" awardedPoints="1" usedAttempts="1"><direction>Is it dangerous to ride a bicycle.
</direction><answers correctAnswerIndex="1" userAnswerIndex="1"><answer>Yes. Riding a bicycle is one of the most dangerous occupations
</answer><answer>False. Riding a bicycle is a safe exercise.
</answer>
and so on. It is then passed to the following html page for interpretation by javascript. I have no reason to doubt that this will work, but I need to deliver the mysql $Result as an xml file. Any help would be much appreciated.