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 dynamically load JS inside JS ?
- How to change favicon dynamically?
- Dynamically generating a QR code using PHP
- How to create dictionary and add key–value pairs dynamically?
- How to dynamically get the content width of a div using AngularJS ?
- How to dynamically get the content height of a div using AngularJS ?
- Create a Form Dynamically using Dform and jQuery
- Change Image Dynamically when User Scrolls Down | Set 2
- How to Dynamically Add/Remove Table Rows using jQuery ?
- How to Load External JS Scripts Dynamically in AngularJS ?
- How to handle events in dynamically created elements in jQuery ?
- How to add input fields dynamically on button click in AngularJS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.