Movie Categories
/* The project locking mechanism is used here to prevent
collisions when the this page and the "videos.htm" page
each try and access the database, possibly simultaneously.
The two pages could easily try and access the database simultaneously
since each page is called from a frame in the same frameset.
Disallowing simultaneous access by locking the project object
can help prevent server errors.
*/
project.lock();
cursor = database.cursor("select DISTINCT category from videos");
/* The following loop dynamically constructs a table which contains
every category in the videos table. Each category becomes a link
that will send the category to the "videos.htm" page, which will
produce a list of movies in that category. */
while (cursor.next()) {
/* The escape() methos changes any spaces that may occur
in a category (e.g. "Science Fiction") so that the category string
may be passed as an argument via the URL, as in an HTTP GET request. */
catstr = escape(cursor.category)
write(cursor.category);
|
} // bottom of while loop
cursor.close()
project.unlock();