我正在尝试使用mysqli数据库升级某些数据。此外,如果用户选择不输入任何内容而不选择(日期)任何内容,那么数据库应保持原样。我找不到代码的问题。
HTML:
<h1>Nastavitve tečajev</h1><br><br>
<form action="viv_settings_tecaji.php" method="post">
Datum termina (izberi ID):
<input type="number" name="ID" required><br><br>
Sprememba tega datuma (če ne želiš spremenit pusti prazno):
<input type="date" name="nov_datum"><br><br>
Sprememba statusa (če želiš da ostane isto vpiši trenutni status!:
<input type="number" name="status"><br><br>
Sprememba števila odprtih mest
<input type="number" name="st_odprtih_mest"><br><br>
<input type="submit">
</form><br>
PHP:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "viverius_education";
$conn = new mysqli($servername, $username, $password, $dbname);
$update_datum = $_POST['nov_datum'];
$update_status = $_POST['status'];
$update_st_odprtih_mest = $_POST['st_odprtih_mest'];
$update_ID = $_POST['ID'];
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$sql = "UPDATE razpisani_tecaji
SET
DATUM = (case when '$update_datum' = '' then DATUM else '$update_datum' end),
STATUS = (case when '$update_status' = '' then STATUS else '$update_status' end),
ST_ODPRTIH_MEST = (case when '$update_st_odprtih_mest' = '' then ST_ODPRTIH_MEST else '$update_st_odprtih_mest' end),
WHERE ID_TECAJA = $update_ID";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
header('Location: viv_settings.php'); exit;
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}$conn->close();
?>
答案 0 :(得分:1)
如果有人需要:解决方案。
static const GLfloat cube_strip[] = {
-1.f, 1.f, 1.f, // Front-top-left
1.f, 1.f, 1.f, // Front-top-right
-1.f, -1.f, 1.f, // Front-bottom-left
1.f, -1.f, 1.f, // Front-bottom-right
1.f, -1.f, -1.f, // Back-bottom-right
1.f, 1.f, 1.f, // Front-top-right
1.f, 1.f, -1.f, // Back-top-right
-1.f, 1.f, 1.f, // Front-top-left
-1.f, 1.f, -1.f, // Back-top-left
-1.f, -1.f, 1.f, // Front-bottom-left
-1.f, -1.f, -1.f, // Back-bottom-left
1.f, -1.f, -1.f, // Back-bottom-right
-1.f, 1.f, -1.f, // Back-top-left
1.f, 1.f, -1.f // Back-top-right
};