delete.php
Gesponsorde koppelingen
PHP script bestanden
<div id="navigation">
<ul>
<li> <a href="index.php"> Home </a></li>
<li> <a href="overzicht.php?nr=0-10&sorteer_asc=1"> Overzicht </a></li>
<li> <a href="logout.php"> Logout </a></li>
</ul>
</div>
<div id="content">
Code (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
if (isset($_GET['deleteid'])){
$id = $_GET['deleteid'];
$query = "DELETE FROM tabel WHERE id = {$id} LIMIT 1";
$result = mysql_query($query, $connection);
if(!$result){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
echo "Deleten van af records succesvol<br />";
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a>";
} elseif (!empty($_POST['1']) && (!empty($_POST['2']))){
$var1 = $_POST['1'];
$var2 = $_POST['2'];
if ($var2 >= $var1){
while ($var1 < $var2){
$query = "DELETE FROM tabel WHERE id={$var1}";
$result = mysql_query($query, $connection);
if(!$result){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
$var1++;
}
$query = "DELETE FROM tabel WHERE id={$var2}";
$result = mysql_query($query, $connection);
if(!$result){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
echo "delete succesvol<br />";
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
} else {
echo "error veld 2 is groter dan veld 1";
}
} elseif (isset($_GET['del']) && $_GET['del'] == "truncate") {
$query = "DELETE FROM tabel";
$query2 = "ALTER TABLE tabel AUTO_INCREMENT =1";
$result = mysql_query($query, $connection);
if(!$result){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
$result2 = mysql_query($query2, $connection);
if(!$result2){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
echo "Deleten van af records: succesvol<br />";
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a>";
} else {
header("Location: overzicht.php?nr=0-10&sorteer_asc=1");
}
?>
if (isset($_GET['deleteid'])){
$id = $_GET['deleteid'];
$query = "DELETE FROM tabel WHERE id = {$id} LIMIT 1";
$result = mysql_query($query, $connection);
if(!$result){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
echo "Deleten van af records succesvol<br />";
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a>";
} elseif (!empty($_POST['1']) && (!empty($_POST['2']))){
$var1 = $_POST['1'];
$var2 = $_POST['2'];
if ($var2 >= $var1){
while ($var1 < $var2){
$query = "DELETE FROM tabel WHERE id={$var1}";
$result = mysql_query($query, $connection);
if(!$result){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
$var1++;
}
$query = "DELETE FROM tabel WHERE id={$var2}";
$result = mysql_query($query, $connection);
if(!$result){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
echo "delete succesvol<br />";
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
} else {
echo "error veld 2 is groter dan veld 1";
}
} elseif (isset($_GET['del']) && $_GET['del'] == "truncate") {
$query = "DELETE FROM tabel";
$query2 = "ALTER TABLE tabel AUTO_INCREMENT =1";
$result = mysql_query($query, $connection);
if(!$result){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
$result2 = mysql_query($query2, $connection);
if(!$result2){
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a><br />";
die("Database query failed: " . mysql_error());
}
echo "Deleten van af records: succesvol<br />";
echo "<a href=\"overzicht.php?nr=0-10&sorteer_asc=1\"> TERUG </a>";
} else {
header("Location: overzicht.php?nr=0-10&sorteer_asc=1");
}
?>
</div>