Generate XML Save File Using PHP And MySQL database

Generate XML Save File Using PHP And MySQL database

Welcome on Pakainfo.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!.

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, '[email protected]', 'admin', 'Active');

Database Connection


 define('DBHOST','localhost');
 define('DBUSER','root');
 define('DBPASS','pakainfo*************');
 define('DBNAME','pakainfo');
 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 .= '';
 $Create_simple_txt .= "".PHP_EOL;
 $Create_simple_txt .= ''.PHP_EOL;
 $query = mysqli_query($db, "SELECT * FROM ".TB_PREF."clients");
 while($values_query = mysqli_fetch_assoc($query)) {
 $Create_simple_txt .= '';
 $Create_simple_txt .= '' .$values_query['ID']. '';
 $Create_simple_txt .= '' .$values_query['uname']. '';
 $Create_simple_txt .= '' .$values_query['pass']. '';
 $Create_simple_txt .= '' .$values_query['client_name']. '';
 $Create_simple_txt .= '' .$values_query['isactive']. '';
 $Create_simple_txt .= '' .$values_query['email']. '';
 $Create_simple_txt .= '' .$values_query['role']. '';
 $Create_simple_txt .= '' .$values_query['default']. '';
 $Create_simple_txt .= ''.PHP_EOL;
 }
$Create_simple_txt .= ''.PHP_EOL;
$Create_simple_txt .= '';
fwrite($fh, $Create_simple_txt);
fclose($fh);

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(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Comment