Lab9: MySQL

Lab9: MySQL
Thesarus: A web service called thesaurus.php has the following behavior:
Word look up query: GET request
Returns a plaintext, space delimited list of synonyms or antonyms for the requested word
Parameter Name
q
mode
Value
The word to look up
“syn” – find synonyms for this word
“ant” – find antonyms for this word
Add related word pair query: POST request
Adds a relationship between two words, either as synonyms or antonyms
Parameter Name
q1
q2
relationship
Value
One word of the relation
Second word of the relation
“syn” – these words are synonyms
“ant” – these words are antonyms
Complete the following:
a) (3pts) Create a JQM page to contain two buttons: “Thesaurus” and “Add Words”.
The “Thesaurus” button should lead to a “Search page” that contains the
following:
b) (3pts) Implement a search form for this thesaurus web service. The starter
HTML is written below. When a user submits the form, you should stop the
form submission event and make an AJAX request to thesaurus.php with the
appropriate parameters to find a synonym or antonym for the requested word.
Upon a successful request, you should display the definition in the paragraph
element with the id of “results.”
<form id="search_form" action=”thesaurus.php”
method=”GET”>
<fieldset>
Search for: <input type="text" id="word" />
<select id="type">
<option>synonyms</option>
<option>antonyms</option>
</select>
<input type="submit" value="Search" />
</fieldset>
</form>
<p id="results"></p>
c) (3pts) The “Add Words” button should lead to the “AddWord page” that
contains the following. Implement a way to add synonyms or antonyms to the
service. The starter HTML is below. Similarly to part a, you should stop the form
submission event and make an AJAX request to thesaurus.php with the
appropriate parameters to add the synonym or antonym pair. Upon a successful
request, you should display “<word 1> and <word 2> added” in the paragraph
element with the id of “results.”
<form action=”addwords.php” method=”post”>
<fieldset>
<input type="text" id="word1" />
and
<input type="text" id="word2" />
are
<select id="type">
<option>synonyms</option>
<option>antonyms</option>
</select>
<input type="submit" value="Add Relationship"
/>
</fieldset>
</form>
<p id="results"></p>
d) (1pt) Implement a top navigation bar and a “back” button on both “Thesaurus” and
“Add Words” pages.
The starter HTML forms should be in the “index.html” file under “lab9” directory. The same
directory should also host the thesaurus.php and addwords.php files.
In the user root directory, there is a MySQL.txt file that contains your database name, user name
and password.
Your database should contain a single table named “thesaurus” with the following structure:
(word1, word2, relationship). Each column is of type “varchar”.
Due: 1 week.
Helpful sites:



Lecture slides: http://www.webstepbook.com/supplements.shtml#slides
Reference links for each chapter:
http://www.webstepbook.com/supplements.shtml#references
Self-checking and programming assignments:
http://www.webstepbook.com/supplements.shtml#exercises