вот так написал
$conn = mysqli_connect($servername, $username, $password, $database);
// Проверяем соединение
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$result = mysqli_query($link, 'SELECT * FROM homework_table');
$currentData = mysqli_fetch_array($result);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$hm2 = $_POST['hm2'];
$hm3 = $_POST['hm3'];
$name = $_POST['name'];
mysqli_query($conn, 'TRUNCATE TABLE homework_table');
mysqli_query($conn, 'INSERT INTO homework_table (name, hm2, hm3');
$sql = "INSERT INTO homework_table (name, hm2, hm3) VALUES ('$name', '$hm2', '$hm3')";
if (!mysqli_query($conn, $sql)) {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
header('Location: ' . $_SERVER['PHP_SELF']);
die();
}
?>
и так попробовал
$conn = mysqli_connect($servername, $username, $password, $database);
$result = mysqli_query($link, 'SELECT * FROM homework_table');
$currentData = mysqli_fetch_array($result);
// Проверяем соединение
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$hm2 = $_POST['hm2'];
$hm3 = $_POST['hm3'];
$name = $_POST['name'];
mysqli_query($conn, 'TRUNCATE TABLE homework_table');
mysqli_query($conn, 'INSERT INTO homework_table (name, hm2, hm3');
$sql = "INSERT INTO homework_table (name, hm2, hm3) VALUES ('$name', '$hm2', '$hm3')";
if (!mysqli_query($conn, $sql)) {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
header('Location: ' . $_SERVER['PHP_SELF']);
die();
}
?>
и так тоже
$conn = mysqli_connect($servername, $username, $password, $database);
// Проверяем соединение
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$hm2 = $_POST['hm2'];
$hm3 = $_POST['hm3'];
$name = $_POST['name'];
$result = mysqli_query($link, 'SELECT * FROM homework_table');
$currentData = mysqli_fetch_array($result);
mysqli_query($conn, 'TRUNCATE TABLE homework_table');
mysqli_query($conn, 'INSERT INTO homework_table (name, hm2, hm3');
$sql = "INSERT INTO homework_table (name, hm2, hm3) VALUES ('$name', '$hm2', '$hm3')";
if (!mysqli_query($conn, $sql)) {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
header('Location: ' . $_SERVER['PHP_SELF']);
die();
}
?>
и даже вот так
$conn = mysqli_connect($servername, $username, $password, $database);
// Проверяем соединение
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$hm2 = $_POST['hm2'];
$hm3 = $_POST['hm3'];
$name = $_POST['name'];
mysqli_query($conn, 'TRUNCATE TABLE homework_table');
mysqli_query($conn, 'INSERT INTO homework_table (name, hm2, hm3');
$sql = "INSERT INTO homework_table (name, hm2, hm3) VALUES ('$name', '$hm2', '$hm3')";
if (!mysqli_query($conn, $sql)) {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
header('Location: ' . $_SERVER['PHP_SELF']);
die();
}
$result = mysqli_query($link, 'SELECT * FROM homework_table');
$currentData = mysqli_fetch_array($result);
?>
никак не работает. сайт просто не грузится