Skip to content

Commit c84b5a0

Browse files
author
Lucy Bain
committed
first commit
0 parents  commit c84b5a0

File tree

5 files changed

+199
-0
lines changed

5 files changed

+199
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

README

Whitespace-only changes.

index.php

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6+
<title>toDo</title>
7+
<link rel="stylesheet" type="text/css" href="style.css" />
8+
</head>
9+
<script type="text/javascript" src="calendarDateInput.js" />
10+
11+
<body>
12+
<div id="wrap">
13+
14+
15+
<div id="main">
16+
17+
<form method="post" action="index.php">
18+
<label for="item">Task:</label>
19+
<input type="text" id="item" name="item" /><br />
20+
<label for="priority">priority:</label>
21+
<input type="text" id="priority" name="priority" /><br />
22+
<input type="submit" value="add" name="submit" />
23+
</form>
24+
25+
<?php
26+
27+
$couch_dsn = "http://localhost:5984/";
28+
$couch_db = "example";
29+
30+
31+
/**
32+
* include the library
33+
*/
34+
35+
require_once "../lib/couch.php";
36+
require_once "../lib/couchClient.php";
37+
require_once "../lib/couchDocument.php";
38+
39+
/**
40+
* create the client
41+
*/
42+
$client = new couchClient($couch_dsn,$couch_db);
43+
44+
45+
46+
47+
if (isset($_POST['item']))
48+
{
49+
$task = $_POST['item'];
50+
$priority = $_POST['priority'];
51+
echo "<p> Added $task</p>";
52+
53+
/* create a new task document */
54+
$todoTask = new StdClass();
55+
$todoTask->_id = $task;
56+
$todoTask->task = $task;
57+
$todoTask->priority = $priority;
58+
59+
/* now try to insert it */
60+
try {
61+
$response = $client->storeDoc($todoTask);
62+
} catch (Exception $e) {
63+
echo "Error: ".$e->getMessage()." (errcode=".$e->getCode().")\n";
64+
exit(1);
65+
}
66+
67+
#print_r($response);
68+
69+
70+
}
71+
72+
$all_docs = $client->getAllDocs();
73+
#echo "Database got ".$all_docs->total_rows." documents.<BR>\n";
74+
echo "<table id=\"hor-minimalist-b\">\n<tr><th>Task</th><th>Priority</th><tr>\n\n";
75+
76+
foreach ( $all_docs->rows as $row ) {
77+
#echo "".$row->id."<BR>\n";
78+
79+
/* this just gets an id so need to retrieve document */
80+
$doc = $client->getDoc($row->id);
81+
$priority = $doc->priority;
82+
$task = $doc->task;
83+
echo "<tr><td >$task</td><td >$priority</td></tr>\n";
84+
}
85+
86+
87+
?>
88+
</table>
89+
90+
91+
92+
93+
</div>
94+
95+
96+
97+
98+
99+
</div>
100+
</body>
101+
</html>

report.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6+
<title>toDo</title>
7+
<link rel="stylesheet" type="text/css" href="style.css" />
8+
</head>
9+
<script type="text/javascript" src="calendarDateInput.js" />
10+
11+
<body>
12+
<div id="wrap">
13+
14+
15+
<div id="main">
16+
17+
<form method="post" action="report.php">
18+
<label for="item">Task:</label>
19+
<input type="text" id="item" name="item" /><br />
20+
<label for="priority">priority:</label>
21+
<input type="text" id="priority" name="priority" /><br />
22+
<input type="submit" value="add" name="submit" />
23+
</form>
24+
25+
<?php
26+
27+
$couch_dsn = "http://localhost:5984/";
28+
$couch_db = "example";
29+
30+
31+
/**
32+
* include the library
33+
*/
34+
35+
require_once "../lib/couch.php";
36+
require_once "../lib/couchClient.php";
37+
require_once "../lib/couchDocument.php";
38+
39+
/**
40+
* create the client
41+
*/
42+
$client = new couchClient($couch_dsn,$couch_db);
43+
44+
45+
46+
47+
if (isset($_POST['item']))
48+
{
49+
$task = $_POST['item'];
50+
$priority = $_POST['priority'];
51+
echo $task;
52+
53+
/* create a new task document */
54+
$todoTask = new StdClass();
55+
$todoTask->_id = $task;
56+
$todoTask->task = $task;
57+
$todoTask->priority = $priority;
58+
59+
/* now try to insert it */
60+
try {
61+
$response = $client->storeDoc($todoTask);
62+
} catch (Exception $e) {
63+
echo "Error: ".$e->getMessage()." (errcode=".$e->getCode().")\n";
64+
exit(1);
65+
}
66+
67+
print_r($response);
68+
69+
70+
}
71+
72+
$all_docs = $client->getAllDocs();
73+
echo "Database got ".$all_docs->total_rows." documents.<BR>\n";
74+
foreach ( $all_docs->rows as $row ) {
75+
echo "".$row->id."<BR>\n";
76+
/* this just gets an id so need to retrieve document */
77+
$doc = $client->getDoc($row->id);
78+
echo $doc->priority;
79+
}
80+
?>
81+
82+
83+
84+
85+
86+
</div>
87+
88+
89+
90+
91+
92+
</div>
93+
</body>
94+
</html>

style.css

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)