#native_company# #native_desc#
#native_cta#

So you want to use a database in your site? Page 4

By Jess Castagnetto
on July 30, 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 />

&nbsp;<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 />&nbsp;<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>


1
|
2
|
3
|
4
|
5
|
6
|
7