Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Employees List</title>
- </head>
- <body>
- <h1>Employees List</h1>
- <?php
- // variables initialization
- $host="localhost";
- $user="user";
- $password="S3cP@ss";
- $db="city_stats";
- // establish a connection
- if ($dbh=mysqli_connect($host, $user, $password, $db)) {
- // initialize the query statement
- $query="SELECT city_name, population FROM cities";
- if ($result=mysqli_query($dbh, $query)) {
- // we have data, so let's list it
- echo "<ol>";
- while ($row=mysqli_fetch_array($result, MYSQL_ASSOC)) {
- echo "<li>".$row['city_name'].", ".$row['population']."</li>";
- }
- echo "</ol>";
- }
- else
- echo "<h2>ERROR: No data!</h2>";
- }
- else
- echo "<h2>ERROR: No connection!</h2>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement