<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "contact"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT name, phone, mobile FROM contact"; $result = $conn->query($sql); if ($result != null) { // output data of each row while($row = $result->fetch_assoc()) { echo "Name: " . $row["name"]. " - Phone: " . $row["phone"]. " " . $row["mobile"]. "<br>"; } } else { echo "0 results"; } $conn->close(); ?>
下載Eclipse
全站熱搜