Example 2: Parsing and querying
June 6, 2000
Here I will show a more complex example, which should make life easier
for the user (who says the developer's life should be easy too :).
Example 2: Parsing and querying
In the first part of this article we made a
straight, no syntax checking, SQL form interface to the database.
Now, I know that some people do not like to write raw SQL, so we will
make a more "user-friendly" HTML form:
query_form.html
<HTML>
<TITLE>Query form</TITLE>
<BODY BGCOLOR="white">
<FORM ACTION="do_query.php3" METHOD="POST">
Find all documents in which:<BR>
the title contains any of these keywords: (*)
<INPUT TYPE="text" NAME="title" SIZE=40>i<BR>
AND<BR>
was written by any of the following: (check as many as needed)<BR>
<INPUT TYPE="checkbox" NAME="author[]" VALUE="Mark Musone"> Mark Musone
<INPUT TYPE="checkbox" NAME="author[]" VALUE="Mattias Nilsson"> Mattias Nilsson
<INPUT TYPE="checkbox" NAME="author[]" VALUE="Rasmus Lerdorf"> Rasmus Lerdorf
<INPUT TYPE="checkbox" NAME="author[]" VALUE="Tim Perdue"> Tim Perdue
<BR>
AND<BR>
was published on or after the year:
<SELECT NAME="pubyear">
<OPTION VALUE="1999" SELECTED>1999</OPTION>
<OPTION VALUE="2000">2000</OPTION>
<OPTION VALUE="2001">2001</OPTION>
</SELECT>
<BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Submit query">
</FORM>
(*) <I>Note</I>: You can enter a comma separated list of keywords, e.g.
"mail,imap,logging" will search for full or partial matches to:
<TT>mail OR imap OR logging</TT> in the title of the article.
</BODY>
</HTML>
Example 1: a simple SQL query interface
So you want to use a database in your site?
3 Different Types of Variables
|