CyberGh0st12
Social Engineer
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
100 XP
Getting Started
In the previous tutorial, we have discussed on How to create XML file from MySQL Database using PHP. As a continuation, this tutorial will discuss on how to display XML files.
I've used bootstrap to improve the design of presentation of this tutorial. This bootstrap is included in the downloadable of this tutorial but, if you want, you may download bootstrap using this link.
Creating our Script
I have included a sample .xml file in the downloadable of this tutorial which I'm going to use to display in the tables of this tutorial.
Create a new file named index.php and paste the codes below.
That ends this tutorial. Happy Coding :)
In the previous tutorial, we have discussed on How to create XML file from MySQL Database using PHP. As a continuation, this tutorial will discuss on how to display XML files.
I've used bootstrap to improve the design of presentation of this tutorial. This bootstrap is included in the downloadable of this tutorial but, if you want, you may download bootstrap using this link.
Creating our Script
I have included a sample .xml file in the downloadable of this tutorial which I'm going to use to display in the tables of this tutorial.
Create a new file named index.php and paste the codes below.
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Display XML File using PHP</title>
- <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
- </head>
- <body>
- <div class="container">
- <h1 class="page-header text-center">Display XML File using PHP</h1>
- <div class="row">
- <div class="col-sm-8 col-sm-offset-2">
- <table class="table table-bordered table-striped">
- <thead>
- <th>UserID</th>
- <th>Firstname</th>
- <th>Lastname</th>
- <th>Address</th>
- </thead>
- <tbody>
- <?php
- //load xml file
- $file
=
simplexml_load_file
(
'files/members.xml'
)
;
- foreach
(
$file
->
user
as
$row
)
{
- ?>
- <tr>
- <td><?php
echo
$row
->
id
;
?>
</td>
- <td><?php
echo
$row
->
firstname
;
?>
</td>
- <td><?php
echo
$row
->
lastname
;
?>
</td>
- <td><?php
echo
$row
->
address
;
?>
</td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </body>
- </html>
That ends this tutorial. Happy Coding :)