Diff between 628dd9c26124ec52ce1d5e28510d37e43a7678fd and d1069bb62ced9fa76e1dffddc79d62dc6bd522b8

Changed Files

File Additions Deletions Status
index.php +1 -0 modified
luku.php +6 -0 modified
poista.php +18 -0 added

Full Patch

diff --git a/index.php b/index.php
index 19d775b..e409713 100755
--- a/index.php
+++ b/index.php
@@ -38,6 +38,7 @@
                   		<th>Status</th>
 				<th>Ruokaraha</th>
 				<th>Muuta</th>
+				<th>Muokkaus</th>
 			</tr>
 		<!-- Ota tiedot tiedot kannasta -->
  		<?php
diff --git a/luku.php b/luku.php
index 5b62f55..9da5f7f 100755
--- a/luku.php
+++ b/luku.php
@@ -18,6 +18,12 @@ if ($result->num_rows>0){
 			echo "<td>" . $row["status"] . "</td>";
 			echo "<td>" . $row["ruokaraha"] . "</td>";
 			echo "<td>" . $row["muuta"] . "</td>";
+			echo "<td>" . // Poista nappi
+				"<form action='poista.php' method='POST'>
+				<input type='hidden' id='id' name='id' value={$row['id']}>
+				<input type='submit' value='Poista'>
+				</form>"
+			       	. "</td>";
 		echo "</tr>";
 	}
 }
diff --git a/poista.php b/poista.php
new file mode 100644
index 0000000..113b830
--- /dev/null
+++ b/poista.php
@@ -0,0 +1,18 @@
+<?php
+// Yhdistä tietokantaan
+include "connect.php";
+// Poista tietokannasta yksi tyyppi ideen avulla
+$id = $_POST["id"];
+$sql = "DELETE FROM oppilaat WHERE id={$id}";
+
+if ($conn->query($sql) === TRUE) {
+  echo "Arvo poistettu onnistuneesti";
+} else {
+  echo "Virhe poistaessa arvoa: " . $conn->error;
+}
+$conn->close();
+// Redirect
+$newURL = "index.php";
+header('Location: '.$newURL);
+die();
+?>