Create XML from MySQL database using PHP
1 post
Page 1 of 1
If you use scripts or your vb project uses XML files. Then here is the easiest way to copy your database to a XML file.
This does work...I have tested on my up and coming new project.
I use this script to create a XML file on the server. Then my project makes a webrequest for this XML file.
And in populates a LIstBox, or ListView, or a TreeView.
The uses are unlimited.
Inside that XML file you will see.
This does work...I have tested on my up and coming new project.
I use this script to create a XML file on the server. Then my project makes a webrequest for this XML file.
And in populates a LIstBox, or ListView, or a TreeView.
The uses are unlimited.
Code: Select all
When this script is executed it will create a file named: MadedList.xml<?php
$host = "HOST";
$user = "USERNAME";
$pass = "USER_PASSWORD";
$database = "DATABASE";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "SELECT * FROM TABLE_NAME ORDER BY FEILD_NAME ASC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>\r\r\n";
$xml_output .= "<entries>\r\r\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<entry>\r\r\n";
$xml_output .= "\t\t<pagename>" . $row['pagename'] . "</pagename>\r\r\n";
$xml_output .= "\t</entry>\r\r\n";
}
$xml_output .= "</entries>\n";
//Optional
//echo $xml_output;
$filenamepath = "MadedList.xml";
$fp = fopen($filenamepath,'w');
$write = fwrite($fp,$xml_output);
?>
Inside that XML file you will see.
Code: Select all
Very simple...very easy.<?xml version="1.0"?>
<entries>
<entry>
<pagename>FEILD_DATA</pagename>
</entry>
<entry>
<pagename>FEILD_DATA</pagename>
</entry>
</entries>
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023