Phpfile
Jump to navigation
Jump to search
<?php $dbhost = 'localhost:3306'; $dbuser = 'root'; $dbpass = 'out'; $conn = mysqli_connect($dbhost, $dbuser, $dbpass); if(! $conn){ die('could not connect '. mysqli_error()); } echo 'Connected Successfully'; mysqli_select_db($conn, 'test'); $query = 'SELECT * FROM posts'; $result = mysqli_query($conn, $query); mysqli_close($conn); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <?php if(mysqli_num_rows($result)> 0):?> <ul> <?php while($row = mysqli_fetch_object($result)): ?> <li><?php echo $row->Name ?></li> <?php endwhile; ?> </ul> <?php else: ?> <p>No post</p> <?php endif; ?> <?php phpinfo(); ?> </body> </html>