Repository navigation
Expand file tree
/
Copy pathedit.php
More file actions
99 lines (90 loc) · 3.1 KB
/
Copy pathedit.php
File metadata and controls
99 lines (90 loc) · 3.1 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
<?php
include_once 'classes.php';
include_once 'header.php';
//include_once 'db.php';
if (isset($_REQUEST["search"])) {
$editable=<<<EOS
<div class="editable">
<form>
<div class="form-row">
<div class="form-group col-md-2">
<label for="word">Word</label>
<input type="hidden" name="id" id="id" value="%s">
<input type="text" class="form-control long-press" name="word" id="word" value="%s">
</div>
<div class="form-group col-md-2">
<label for="translation">Translation</label>
<input type="text" class="form-control long-press" name="translation" id="translation" value="%s">
</div>
<div class="form-group col-md-6">
<label for="noteS">Notes</label>
<textarea class="form-control rounded-0 long-press" name="Notes" id="Notes" rows="4">%s</textarea>
</div>
<div class="form-group col-md-2">
<button onclick="" id= "modify" name="modify" class="btn btn-primary">Modify</button>
<button onclick="" id= "delete" name="delete" class="btn btn-primary">Delete</button>
</div>
</div>
</form>
</div>
EOS;
$w = new word();
// add the information to the database
foreach ($_REQUEST as $param_name => $param_val) {
${$param_name}=$param_val;
//echo "$param_name = $param_val<br/>\n";
};
$results=$w->search($searchTerm);
if (count($results) < 1 ) {
echo "<div class='error'> no results found for search string '$searchTerm'</div>\n";
} else {
echo "<div class='information'>".count($results)." ".(count($results)==1 ? "result" : "results")."</div>";
foreach ($results as $result) {
echo sprintf($editable,$result->id, $result->word, $result->translation, $result->Notes);
}
}
} elseif (isset($_REQUEST["modify"])) {
$w = new word();
// get all the request vars
foreach ($_REQUEST as $param_name => $param_val) {
${$param_name}=$param_val;
echo "$param_name = $param_val<br/>\n";
};
$w->modify($id, $word, $translation, $Notes);
echo "Modified $word<br/>\n";
// Close connection
//mysqli_close($dbh);
} elseif (isset($_REQUEST["delete"])) {
$w = new word();
// get all the request vars
foreach ($_REQUEST as $param_name => $param_val) {
${$param_name}=$param_val;
//echo "$param_name = $param_val<br/>\n";
};
$w->delete($id);
echo "Deleted $word<br/>\n";
// Close connection
//mysqli_close($dbh);
} else {
?>
<div class="search">
<form>
<div class="form-row">
<div class="form-group col-md-4">
<label for="search">Search for:</label>
<input type="text" class="form-control long-press" name="searchTerm" id="searchTerm" placeholder="Search term" default>
</div>
<div class="form-group col-md-8">
</div>
<button type="submit" id= "search" name="search" class="btn btn-primary">search</button>
</div>
</form>
</div>
<script >$(function(){
$('.long-press').longPress();
document.getElementById("searchTerm").focus();
});</script>
<?php
}
include_once 'footer.php';
?>