-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
71 lines (53 loc) · 1.72 KB
/
search.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
67
68
69
70
71
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>toDo</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<script type="text/javascript" src="calendarDateInput.js"></script>
<body>
<div id="wrap">
<table border="0" cellpadding="0" cellspacing="0" width="600">
<tr><td align="right">
<form action="search.php" method="post">
<input type="text" name="searchid" value="" style="color: #000000; background: #FFFFFF">
<input type="submit" value="Search">
</form>
</td></tr>
</table>
<div id="main">
<?php
$couch_dsn = "http://localhost:5984/";
$couch_db = "nosql";
require_once "couch.php";
require_once "couchClient.php";
require_once "couchDocument.php";
$client = new couchClient($couch_dsn,$couch_db);
if (!isset($_POST['searchid']) || $_POST['searchid'] == "") {
//Redirect to index
echo('<meta http-equiv="refresh" content="0;url=index.php">');
exit;
}
$all_docs = $client->getAllDocs();
echo "<table id=\"hor-minimalist-b\">\n<tr><th>Title</th><th>Body</th><tr>\n\n";
$foundsearch = 0;
foreach ( $all_docs->rows as $row ) {
$doc = $client->getDoc($row->id);
if ((stristr($doc->title, $_POST['searchid']) !== FALSE) || (stristr($doc->body, $_POST['searchid']) !== FALSE)) {
$foundsearch = 1;
$body = $doc->body;
$title = $doc->title;
echo "<tr><td ><a href='entry_display.php?title=$title'>$title</a></td><td >$body</td></tr>\n";
}
}
if ($foundsearch == 0) {
echo "<tr><td colspan=\"2\">No Results Found</td></tr>\n";
}
?>
</table>
</div>
</div>
</body>
</html>