建立資料表
按新增 把資料打進去
資料就建好了
接下來把資料顯示在網頁上
創一個文字檔 把檔名改成xxx.php
放到對的位置
程式碼
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM `user`";
$result = $conn->query($sql);
if ($result != null) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["name"]. $row["passwd"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
然後就
接下來把資料顯示在網頁上
創一個文字檔 把檔名改成xxx.php
放到對的位置
程式碼
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM `user`";
$result = $conn->query($sql);
if ($result != null) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["name"]. $row["passwd"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
然後就
沒有留言:
張貼留言