-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsomething.php
More file actions
100 lines (49 loc) · 1.31 KB
/
something.php
File metadata and controls
100 lines (49 loc) · 1.31 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/*
template name: a demo template
*/
global $wpdb;
?>
<?php if ( is_user_logged_in() && current_user_can('delete_others_pages') ) : ?>
<form action="" method="POST">
<input type="text" name="naam" placeholder="please type your name">
<input type="submit" value="submit" name="namesubmit">
</form>
<?php endif; ?>
<p></p>
<br>
<hr>
<?php
global $wpdb;
$tablename = $wpdb->prefix . 'sujan';
$infos = $wpdb->get_results("SELECT * FROM $tablename");
foreach($infos as $info){
$id = $info->id;
$editlink = '?edit='.$id;
$deletelink = '?delete='.$id;
echo $id . ' ' . $info->name . '<a href="'.$editlink.'">edit</a>' . ' <a href="'.$deletelink.'">delete</a>' . "<br />";
}
?>
<br>
<hr>
<?php if( isset( $_GET['edit'] ) ) : ?>
<?php
$id = $_GET['edit'];
$value = $wpdb->get_var("SELECT name FROM $tablename WHERE id = $id");
?>
<form action="" method="POST">
<input type="text" name="naam" placeholder="please type your name" value="<?php echo $value; ?>">
<input type="submit" value="submit" name="nameupdate">
</form>
<?php endif; ?>
<?php
$deleteid = isset( $_GET['delete'] ) ? $_GET['delete'] : '';
if(!empty($deleteid)){
$wpdb->delete($tablename, array(
'id' => $deleteid
));
global $post;
$id = $post->ID;
wp_redirect(get_page_link($id));
}
?>