Formular in eine MySQL Datenbank speichern

SockenKrieger24

Schraubenverwechsler(in)
Hallo ich habe folgende Aufgabe bekommen:

Es soll eine kleine und simple FAQ Anwendung entwickelt werden welche HTML, CSS, PHP, JavaScript & MySQL Komponenten beinhaltet.Es sollen zunächst Bereichsgruppen (bzw. Themenschwerpunkte wie Allgemein, Abrechnung, ...) angelegt werden. Anschließend sollen Fragen samt Antworten erstellt werden, die einer oder mehrerer Bereichsgruppen zugeordnet werden können. Zur Anlegung von Bereichsgruppen wie auch für Fragen und Antworten soll es jeweils ein Formular geben, dessen Eingaben in einer MySQL/MariaDB Datenbank gespeichert werden. Auf einer weiteren Seite sollen die Bereichsgruppen samt zugehöriger Fragen und Antworten ausgegeben werden.

Ich habe vorher noch nie mit MySQL gearbeitet und weiß daher nicht was ich damit machen soll. Könnte mir jemand vielleicht erklären was ich machen soll?
 
du erzeugst in php ein db Objekt (mysqli) dem die entsprechenden methoden(siehe php.net) zum db Handling zur Verfügung stehen und nutzt dieses dann um auf die db zuzugreifen, hab einfach mal das beispiel von w3schools angehängt:

Code:
[COLOR=red][FONT=Consolas]<?php[/FONT][COLOR=#000000][FONT=Consolas]$servername = [/FONT][COLOR=brown][FONT=Consolas]"localhost"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT][COLOR=#000000][FONT=Consolas]$username = [/FONT][COLOR=brown][FONT=Consolas]"username"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT][COLOR=#000000][FONT=Consolas]$password = [/FONT][COLOR=brown][FONT=Consolas]"password"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT][COLOR=#000000][FONT=Consolas]$dbname = [/FONT][COLOR=brown][FONT=Consolas]"myDB"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT]
[COLOR=green][FONT=Consolas]// Create connection
[/FONT][COLOR=#000000][FONT=Consolas]$conn = [/FONT][COLOR=mediumblue][FONT=Consolas]new[/FONT][COLOR=#000000][FONT=Consolas] mysqli($servername, $username, $password, $dbname);[/FONT][COLOR=green][FONT=Consolas]// Check connection
[/FONT][COLOR=mediumblue][FONT=Consolas]if[/FONT][COLOR=#000000][FONT=Consolas] ($conn->connect_error) {[/FONT][COLOR=mediumblue][FONT=Consolas]die[/FONT][COLOR=#000000][FONT=Consolas]([/FONT][COLOR=brown][FONT=Consolas]"Connection failed: "[/FONT][COLOR=#000000][FONT=Consolas] . $conn->connect_error);[/FONT][COLOR=#000000][FONT=Consolas]} [/FONT]
[COLOR=#000000][FONT=Consolas]$sql = [/FONT][COLOR=brown][FONT=Consolas]"SELECT id, firstname, lastname FROM MyGuests"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT][COLOR=#000000][FONT=Consolas]$result = $conn->query($sql);[/FONT]
[COLOR=mediumblue][FONT=Consolas]if[/FONT][COLOR=#000000][FONT=Consolas] ($result->num_rows > [/FONT][COLOR=red][FONT=Consolas]0[/FONT][COLOR=#000000][FONT=Consolas]) {[/FONT][COLOR=mediumblue][FONT=Consolas]echo[/FONT][COLOR=brown][FONT=Consolas]"<table><tr><th>ID</th><th>Name</th></tr>"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT][COLOR=green][FONT=Consolas]// output data of each row
[/FONT][COLOR=mediumblue][FONT=Consolas]while[/FONT][COLOR=#000000][FONT=Consolas]($row = $result->fetch_assoc()) {[/FONT][COLOR=mediumblue][FONT=Consolas]echo[/FONT][COLOR=brown][FONT=Consolas]"<tr><td>"[/FONT][COLOR=#000000][FONT=Consolas].$row[[/FONT][COLOR=brown][FONT=Consolas]"id"[/FONT][COLOR=#000000][FONT=Consolas]].[/FONT][COLOR=brown][FONT=Consolas]"</td><td>"[/FONT][COLOR=#000000][FONT=Consolas].$row[[/FONT][COLOR=brown][FONT=Consolas]"firstname"[/FONT][COLOR=#000000][FONT=Consolas]].[/FONT][COLOR=brown][FONT=Consolas]" "[/FONT][COLOR=#000000][FONT=Consolas].$row[[/FONT][COLOR=brown][FONT=Consolas]"lastname"[/FONT][COLOR=#000000][FONT=Consolas]].[/FONT][COLOR=brown][FONT=Consolas]"</td></tr>"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT][COLOR=#000000][FONT=Consolas]    }[/FONT][COLOR=mediumblue][FONT=Consolas]echo[/FONT][COLOR=brown][FONT=Consolas]"</table>"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT][COLOR=#000000][FONT=Consolas]} [/FONT][COLOR=mediumblue][FONT=Consolas]else[/FONT][COLOR=#000000][FONT=Consolas] {[/FONT][COLOR=mediumblue][FONT=Consolas]echo[/FONT][COLOR=brown][FONT=Consolas]"0 results"[/FONT][COLOR=#000000][FONT=Consolas];[/FONT][COLOR=#000000][FONT=Consolas]}[/FONT][COLOR=#000000][FONT=Consolas]$conn->close();[/FONT][COLOR=red][FONT=Consolas]?>[/FONT]
 
Zurück