Folder reorganize 1
This commit is contained in:
47
test/aitest
Normal file
47
test/aitest
Normal file
@@ -0,0 +1,47 @@
|
||||
function DROPDOWN list from mysql database and display results in a table using php
|
||||
|
||||
```
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
$servername = "localhost";
|
||||
$username = "root";
|
||||
$password = "";
|
||||
$dbname = "aitest";
|
||||
|
||||
// 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
|
||||
echo "<table><tr><th>ID</th><th>Name</th><th>Lastname</th></tr>";
|
||||
while($row = $result->fetch_assoc()) {
|
||||
echo "<tr><td>".$row["id"]."</td><td>".$row["firstname"]."</td><td>".$row["lastname"]."</td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "0 results";
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user