📅  最后修改于: 2023-12-03 15:35:40.981000             🧑  作者: Mango
Weronika Goretzki is a skilled PHP developer with several years of experience in the field. She has worked on a variety of projects ranging from simple websites to complex web applications. With her deep understanding of PHP and related technologies, she is able to create high-quality, efficient code that meets the needs of clients.
Bachelor's Degree in Computer Science, XYZ University
// Connect to database
$host = 'localhost';
$username = 'username';
$password = 'password';
$dbname = 'database_name';
$conn = mysqli_connect($host, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Select data from table
$sql = "SELECT id, name, email FROM users";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["name"]. " - Email: " . $row["email"]. "<br>";
}
} else {
echo "0 results";
}
mysqli_close($conn);
Markdown:
```php
// Connect to database
$host = 'localhost';
$username = 'username';
$password = 'password';
$dbname = 'database_name';
$conn = mysqli_connect($host, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Select data from table
$sql = "SELECT id, name, email FROM users";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["name"]. " - Email: " . $row["email"]. "<br>";
}
} else {
echo "0 results";
}
mysqli_close($conn);