Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header("Content-type:text/xml");
- header("Access-Control-Allow-Origin: *");
- $host = "localhost";
- $username = "root";
- $password = "";
- $db = "xml";
- $con = mysqli_connect($host, $username, $password, $db);
- $query = mysqli_query($con, "SELECT * FROM student");
- $xml = new SimpleXMLElement('<list/>');
- while($row = mysqli_fetch_array($query)){
- $student = $xml->addChild("student");
- $student -> addChild("name", $row["name"]);
- $student -> addChild("matric_no", $row["matric_no"]);
- $marks = $student->addChild("marks");
- $marks -> addChild("cw", $row["cw"] );
- $marks -> addChild("fe",$row["fe"]);
- }
- mysqli_close($con);
- echo $xml->asXML();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement