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 ?
- Dynamically generating a QR code using PHP
- How to change favicon dynamically?
- How to create dictionary and add key–value pairs dynamically?
- How to dynamically get the content width of a div using AngularJS ?
- How to Load External JS Scripts Dynamically in AngularJS ?
- Change Image Dynamically when User Scrolls Down | Set 2
- How to Dynamically Add/Remove Table Rows using jQuery ?
- How to add input fields dynamically on button click in AngularJS ?
- How to create button dynamically with click event in Angular ?
- How to handle events in dynamically created elements in jQuery ?
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.