Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as PHP by efdf ( 12 years ago )
<?php

// Start XML file, create parent node

$dom = new DOMDocument("1.0");
$node = $dom->createElement("Samtutor");
$parnode = $dom->appendChild($node);

// Opens a connection to a MySQL server
$username="root";
$password="";
$database="samcorgo_samtutor";

$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {  die('Not connected : ' . mysql_error());}

// Set the active MySQL database

$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can't use db : ' . mysql_error());
}

// Select all the rows in the markers table

$query = "SELECT * FROM examset";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header("Content-type: text/xml");

// Iterate through the rows, adding XML nodes for each

while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
  $node = $dom->createElement("Examset");
  $node = $dom->createElement("IDs");
  $newnode = $parnode->appendChild($node);
  $newnode->setAttribute("orgaId",$row['OrganizationID']);
  $newnode->setAttribute("courseId", $row['CourseID']);
  $newnode->setAttribute("ClassId", $row['ClassID']);
  $newnode->setAttribute("SubId", $row['SubjectID']);
  $newnode->setAttribute("PaperId", $row['PaperID']);
}

//echo $dom->saveXML();
$dom->save("asssa.xml")

?>

 

Revise this Paste

Your Name: Code Language: