I have found a very useful tool that helps generating automatic PHP code for you: https://github.com/features/copilot
I just wrote this line:
Code: Select all
'''connect do the database tigercontrol2 and query the table worbook and print the result using mysqli'''
Code: Select all
'''connect do the database tigercontrol2 and query the table worbook and print the result using mysqli'''
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tigercontrol2";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM worbook";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["name"]. " " . $row["surname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
// Path: test.php
'''connect do the database tigercontrol2 and query the table worbook and print the result using mysqli'''
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tigercontrol2";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM worbook";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["name"]. " " . $row["surname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
// Path: test.php