-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
103 lines (85 loc) · 2.55 KB
/
index.php
File metadata and controls
103 lines (85 loc) · 2.55 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
101
102
103
<!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>Mini Wiki</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">
<!--
<form method="post" action="index.php">
<label for="title">Title:</label>
<input type="text" id="title" name="title" /><br />
<label for="body">Body:</label>
<textarea id="body" name="body" rows = 10></textarea><br />
<input type="submit" value="Publish" name="submit" />
</form>
-->
<?php
$couch_dsn = "http://localhost:5984/";
$couch_db = "nosql";
/**
* include the library
*/
require_once "couch.php";
require_once "couchClient.php";
require_once "couchDocument.php";
/**
* create the client
*/
$client = new couchClient($couch_dsn,$couch_db);
/*
if (isset($_POST['title']))
{
$title = $_POST['title'];
$body = $_POST['body'];
echo "<p> Added $title</p>";
*/
/* create a new task document */
$article = new StdClass();
$article->_id = $title;
$article->title = $title;
$article->body = $body;
/* now try to insert it */
/*
try {
$response = $client->storeDoc($article);
} catch (Exception $e) {
echo "Error: ".$e->getMessage()." (errcode=".$e->getCode().")\n";
exit(1);
}
*/
#print_r($response);
/*
}
*/
$all_docs = $client->getAllDocs();
#echo "Database got ".$all_docs->total_rows." documents.<BR>\n";
echo "<table id=\"hor-minimalist-b\">\n<tr><th>Title</th><th>Body</th><tr>\n\n";
foreach ( $all_docs->rows as $row ) {
#echo "".$row->id."<BR>\n";
/* this just gets an id so need to retrieve document */
$doc = $client->getDoc($row->id);
$body = $doc->body;
$title = $doc->title;
echo "<tr><td ><a href='entry_display.php?title=$title'>$title</a></td><td >$body</td></tr>\n";
}
?>
</table>
<button style="width:65; height:65" onClick="window.location='http://localhost/noSQL/addArticle.php'">Add an Article</button>
</div>
</div>
</body>
</html>