-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriviaxml.php
More file actions
45 lines (34 loc) · 1.22 KB
/
triviaxml.php
File metadata and controls
45 lines (34 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require_once 'lib/includes/utilities.inc.php';
$x = 0;
function parseToXML($htmlStr) {
$original = ['<', '>', '"', "", '&'];
$replace = ['<', '>', '"', ''', '&'];
$xmlStr = str_replace($original, $replace, $htmlStr);
return $xmlStr;
}
use website_project\trivia_game\Trivia;
$gamePlay = new Trivia();
$end = filter_input(INPUT_POST, 'end');
if (isset($end)) {
$start = filter_input(INPUT_POST, 'start');
$category = filter_input(INPUT_POST, 'category');
$data = $gamePlay->read($start, $end, $category);
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
while ($x < count($data)) {
echo '<marker ';
echo 'id="' . parseToXML($data[$x]->id) . '" ';
echo 'question="' . parseToXML($data[$x]->question) . '" ';
echo 'answer1="' . parseToXML($data[$x]->answer1) . '" ';
echo 'answer2="' . parseToXML($data[$x]->answer2) . '" ';
echo 'answer3="' . parseToXML($data[$x]->answer3) . '" ';
echo 'answer4="' . parseToXML($data[$x]->answer4) . '" ';
echo 'correct="' . parseToXML($data[$x]->correct) . '" ';
echo 'category="' . parseToXML($data[$x]->category) . '" ';
echo '/>';
$x += 1;
}
echo '</markers>';