Generate XML Save File Using PHP And MySQL database

Generate XML Save File Using PHP And MySQL database

Welcome on live24u.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Generate XML Save File Using PHP And MySQL database

In this post we will show you Best way to implement Generate XML Page using PHP with Mysq, hear for How to Generating xml file by reading data from MySQL table in PHP with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

You can download source code and Demo from below link.




Also Read :   AngularJS RESTful Web Service GET and POST API

XML simple files are the best way to all the web pages handle the export all data and imports or link data’s. Generate XML file using here example of PHP and MySQL is not any much complicated.

Creating MYSQL table

CREATE TABLE IF NOT EXISTS `clients` (
 `ID` int(11) NOT NULL AUTO_INCREMENT,
 `uname` varchar(255) NOT NULL DEFAULT '',
 `pass` varchar(60) NOT NULL DEFAULT '',
 `client_name` varchar(250) NOT NULL,
 `isactive` varchar(30) DEFAULT NULL,
 `email` varchar(255) NOT NULL DEFAULT '',
 `role` varchar(30) NOT NULL,
 `default` varchar(30) NOT NULL,
 PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

INSERT INTO `clients` (`ID`, `uname`, `pass`, `client_name`, `isactive`, `email`, `role`, `default`) VALUES
(1, 'root', '$P$JayMayur982555656898565656.', 'root', NULL, 'info@live24u.com', 'admin', 'Active');

Database Connection


 define('DBHOST','localhost');
 define('DBUSER','root');
 define('DBPASS','live24u*************');
 define('DBNAME','live24u');
 define('TB_PREF','crate_cms_');
$db = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME);
if(!$db){
 die( "Sorry! There simple seems to be a some problem connecting to we database.");
}

Creating XML File

$cfille = "rss.xml";
$fh = fopen($cfille, 'w') or die("can't not open file"); 

Generate Simple XML File Using PHP And MySQL

$Create_simple_txt .= '<?xml version="1.0" encoding="utf-8"?>';
 $Create_simple_txt .= "<rss version='2.0'>".PHP_EOL;
 $Create_simple_txt .= '<clients>'.PHP_EOL;
 $query = mysqli_query($db, "SELECT * FROM ".TB_PREF."clients");
 while($values_query = mysqli_fetch_assoc($query)) {
 $Create_simple_txt .= '<user>';
 $Create_simple_txt .= '<ID>' .$values_query['ID']. '</ID>';
 $Create_simple_txt .= '<uname>' .$values_query['uname']. '</uname>';
 $Create_simple_txt .= '<pass>' .$values_query['pass']. '</pass>';
 $Create_simple_txt .= '<client_name>' .$values_query['client_name']. '</client_name>';
 $Create_simple_txt .= '<isactive>' .$values_query['isactive']. '</isactive>';
 $Create_simple_txt .= '<email>' .$values_query['email']. '</email>';
 $Create_simple_txt .= '<role>' .$values_query['role']. '</role>';
 $Create_simple_txt .= '<default>' .$values_query['default']. '</default>';
 $Create_simple_txt .= '</user>'.PHP_EOL;
 }
$Create_simple_txt .= '</clients>'.PHP_EOL;
$Create_simple_txt .= '</rss>';
fwrite($fh, $Create_simple_txt);
fclose($fh);

You can download source code and Demo from below link.




Also Read :   Simple Multiple Countdown timers using jquery

Example

I hope you have Got how to create xml files via php and Mysql And how it works.I would Like to have FeadBack From My Blog(live24u.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(live24u.com) Are Most Always Welcome.

   

Add a Comment

Your email address will not be published.