-
Notifications
You must be signed in to change notification settings - Fork 0
/
atualizar.php
33 lines (28 loc) · 964 Bytes
/
atualizar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html>
<head>
<title>Atualizar Banco de Dados</title>
</head>
<body>
<?php
// Connect to the database
$conn = mysqli_connect("localhost", "root", "", "trabalho5");
// Check connection
if (!$conn) {
die("Conexão falhou: " . mysqli_connect_error());
}
// Get the submitted data
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$nids = $_POST;
unset($nids["sub"]);
// Loop through the submitted data and update the database
foreach ($nids as $nid => $approval_status) {
$nid_parts = explode("_", $nid);
$nid = $nid_parts[0];
$sid = $nid_parts[1];
$sql = "UPDATE nome_da_tabela SET approval_status = '$approval_status' WHERE nid = $nid AND sid = $sid";
mysqli_query($conn, $sql);
}
// Redirect back to the form
header("Location: atualizar.html");
exit