How can PHP be used to create a learning program for users to input and view "Fachbegriffe" and their meanings in a structured way?
To create a learning program for users to input and view "Fachbegriffe" and their meanings in a structured way, you can use PHP to create a simple web application with a form for users to input terms and their meanings, and a display section to view the stored terms. You can use PHP to handle form submissions, store the terms and meanings in a database, and retrieve and display them on the webpage.
<?php
// Connect to database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "learning_program";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$term = $_POST['term'];
$meaning = $_POST['meaning'];
// Insert term and meaning into database
$sql = "INSERT INTO fachbegriffe (term, meaning) VALUES ('$term', '$meaning')";
$conn->query($sql);
}
// Display stored terms and meanings
$sql = "SELECT term, meaning FROM fachbegriffe";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "Term: " . $row["term"]. " - Meaning: " . $row["meaning"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>