Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server = 'localhost';
- $user='root';
- $pass='';
- $db='cdkatalog';
- try {
- $con=new mysqli($server,$user,$pass,$db) or die("Greska!");
- } catch (Exception $exc) {
- echo $exc->getTraceAsString();
- }
- $sql='select * from cd';
- $rezultat = $con->query($sql);
- $xml = new DOMDocument('1.0');
- $xml->formatOutput = true;
- $catalog = $xml->createElement('CATALOG');
- $xml->appendChild($catalog);
- while($row=$rezultat->fetch_assoc()){
- $cd = $xml->createElement('CD');
- $cd->setAttribute("id", $row['id']);
- $catalog->appendChild($cd);
- $title=$xml->createElement('TITLE', $row['title']);
- $cd->appendChild($title);
- $artist=$xml->createElement('ARTIST', $row['artist']);
- $cd->appendChild($artist);
- $country=$xml->createElement('COUNTRY', $row['country']);
- $cd->appendChild($country);
- $company=$xml->createElement('COMPANY', $row['company']);
- $cd->appendChild($company);
- $price=$xml->createElement('PRICE', $row['price']);
- $cd->appendChild($price);
- $year=$xml->createElement('YEAR', $row['year']);
- $cd->appendChild($year);
- }
- $xml->saveXML();
- $xml->save("xmlFROMdb.xml");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement