Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Initalize server credential varables
- $servername = "localhost";
- $username = "root";
- $password = "root";
- $dbname = "infx2070";
- //create connection
- $conn = new mysqli($servername, $username, $password, $infx2070);
- //check for connection status
- if($conn->connect_error){
- die("connection failed: " . $conn->connect_error . "<br>");
- } else {
- echo "Connection successful! <br>";
- }
- $sql = "SELECT C_id, first_name, last_name, Comment FROM Comments";
- $result = $conn->query($sql);
- if($result->num_rows > 0) {
- //output data of each row
- while($row = $result->fetch_assoc()) {
- echo "id: " . $row["C_id"] . " - Name: " . $row["first_name"] . " "
- . $row["last_name"] . " - Comment: " . $row["Comment"] . "<br>";
- }
- } else {
- echo "0 result <br>";
- }
- $conn->close();
- echo "Connection closed <br>";
- ?>
Add Comment
Please, Sign In to add comment