Search

Send us your query and issues for any kind of problems, We will resolve you problem within next 12 hours, guaranteed ! you can mail us : support@komantech.in

Show Data in Table from Database | PHP Script


Related image

Copy below code & replace server, username, password, database and query($sql)

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
?>


For any further query or help, feel free to contact us : support@komantech.in

Post a Comment

0 Comments