A file can be generated using PHP from the database and it can be done by the static or dynamic method in PHP. Static methods can be called directly – without creating an instance of a class. Here we are going to discuss how to create an XML file dynamically.
$result=mysql_query("Select * from Table_name");
$xml = new DOMDocument("1.0");
The next thing we need to do is fetch the elements from the table.
Example: If a table has two elements then it should create two XML elements. For that, we will simply use a while loop inside which there will be mysql_fetch_array function to fetch all the data from the table.
Since the database is connected to a local server it won’t run in your ide but once you have made the database it will work fine. To create the database follow the below mentioned procedure
- Create a database fitness in mysql using local server.
- Then create a table user.
- Then add the columns-uid, uname, email, password, description, role, pic.
- How to convert XML file into array in PHP?
- Convert multidimensional array to XML file in PHP
- Dynamically generating a QR code using PHP
- How to parse and process HTML/XML using PHP ?
- PHP | XMLReader XML() Function
- How to dynamically get the content width of a div using AngularJS ?
- How to Dynamically Add/Remove Table Rows using jQuery ?
- How to dynamically get the content height of a div using AngularJS ?
- Create a Form Dynamically using Dform and jQuery
- How to dynamically set the height and width of a div element using jQuery ?
- How to set id attribute of an element dynamically using AngularJS ?
- How to calculate area of circle dynamically using amp-bind-macro in Google AMP ?
- How to change/update image size dynamically using amp-bind in Google AMP ?
- How to change/update CSS class dynamically using amp-bind in Google AMP ?
- How to change/update text dynamically using amp-bind in Google AMP ?
- How to change/update image dynamically using amp-bind in Google AMP ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.