Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //1. Database conecction
- $dbhost = "localhost";
- $dbuser = "josepojw_Trainer";
- $dbpass = "locker011";
- $dbname = "josepojw_Testing";
- $connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
- //Test is connection works
- if(mysqli_connect_errno()){
- die("connection failed" . mysqli_connect_error() . "(". mysqli_connect_errno() .")");
- }
- ?>
- <?php
- //2. Perform query
- $query = "SELECT * FROM login";
- $result = mysqli_query($connection, $query);
- //test if query error
- if(!$result){
- die("query failed");
- }
- ?>
- <?php
- //3.Use returned data
- while($row = mysqli_fetch_row($result)){
- //get the first row and assign to the variable, loop increment
- var_dump($row);
- //output from each row
- echo "<hr />";
- //horizontal line tag
- }
- ?>
- <?php
- //4. Release the data
- mysqli_free_result($result);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>database</title>
- </head>
- <body>
- </body>
- </html>
- <?php
- //5. Close the connection
- mysqli_close($connection);
- ?>
Add Comment
Please, Sign In to add comment