Jump to content
php.lv forumi

MySql uz XML


Ernijs_E

Recommended Posts

Protams, noteikti eksistē arī gatavi rīki tā darīšanai...

Eksistet, jau droši vien eksistē, bet ņemot vērā to ka vienkārša XML faila gadījumā kods sastāv burtiski no pāris desmitu rindiņām, varu iedomāties kāds koda blāķis būs gatavam risinājumam.

Kārtējo reizi: klase lai pieslēgtos DB, klase lai izvadītu no DB, klase lai konfigurētu XML tāgus utt.

---

EDIT:

primitīvā varjantā:

<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
//  ####################
$db=mysql_connect($hosts, $users, $paswords);
mysql_select_db("$dbname");
mysql_query("SET NAMES UTF8");
//  ####################
$query="SELECT a1, a2, a3 FROM tabulis ";
$result= mysql_query($query);
print "<pirmais_taags>\r\n";
while($row=mysql_fetch_array($result)){
 print "<a1_taags>".$row['a1']."</a1_taags>\r\n";
 print "<a2_taags>".$row['a2']."</a2_taags>\r\n";
 print "<a3_taags>".$row['a3']."</a3_taags>\r\n";
}
print "</pirmais_taags>\r\n";
mysql_free_result($result);
?>

Edited by Grey_Wolf
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...