php读取mysql中signup表里面的id,zhanghao,mima
时间: 2023-05-11 13:06:18 浏览: 172
PHP MySQL 读取数据
可以使用以下代码来读取mysql中signup表里面的id,zhanghao,mima:
```
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检查连接
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error);
}
$sql = "SELECT id, zhanghao, mima FROM signup";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - zhanghao: " . $row["zhanghao"]. " - mima: " . $row["mima"]. "<br>";
}
} else {
echo "0 结果";
}
$conn->close();
?>
```
请注意,这只是一个示例代码,您需要根据您的实际情况进行修改。
阅读全文