|
WebKeystone Example 6: Accessing and searching a database using visitor input as search criteria
The Form
The Files
<FORM METHOD="POST" ACTION="/wkstone/webkeystone.py">
<INPUT TYPE="HIDDEN" NAME="UserID" VALUE="biz_webkeystone">
<INPUT TYPE="HIDDEN" NAME="Profile" VALUE="examples/example6.prof">
<CENTER>
<TABLE BORDER="1" CELLPADDING="5" CELLSPACING="0" WIDTH="90%" BGCOLOR="#FFFFCC" COLS="2">
<TR>
<TD>
<P>
<TABLE BORDER="0" WIDTH="90%">
<TR>
<TD ALIGN="CENTER" COLSPAN="2">
<P ALIGN="CENTER"><FONT SIZE="4" COLOR="#000000">Find the right KPS doctor for you by selecting a specialty and a location from the menus below and clicking the "Search" button.</FONT>
</TD>
</TR>
<TR>
<TD>
<P ALIGN="RIGHT"><FONT COLOR="#000000">Choose the specialty you are looking for from this pull-down list:</FONT>
</TD>
<TD><SELECT NAME="specialty">
<OPTION>ANESTHESIOLOGY
<OPTION>FAMILY PRACTICE
<OPTION>GENERAL PRACTICE
<OPTION>GENERAL SURGERY
<OPTION>INFECTIOUS DISEASE
<OPTION>INTERNAL MEDICINE
<OPTION>OBSTETRICS/GYNECOLOGY
<OPTION>OPHTHALMOLOGY
<OPTION>ORTHOPEDIC SURGERY
<OPTION>OTOLARYNGOLOGY
<OPTION>PSYCHIATRY
<OPTION>RADIOLOGY
</SELECT></TD>
</TR>
<TR>
<TD>
<P ALIGN="RIGHT"><FONT COLOR="#000000">Select a city from this pull-down list:</FONT>
</TD>
<TD><SELECT NAME="city">
<OPTION>any city
<OPTION>Forks
<OPTION>Port Angeles
<OPTION>Port Townsend
<OPTION>Sequim
</SELECT></TD>
</TR>
</TABLE>
<CENTER>
<INPUT TYPE="SUBMIT" VALUE="Search the KPS Doctors Database">
</CENTER>
</TD>
</TR>
</TABLE>
</CENTER>
</FORM>
# Profile for KPS Doctors Database Search
# Access the database
db = wkdb.database(public('sqlData'))
# If there is no city preference
IF city=='any city'
# Search the database re: 'Specialty'
result = db.get('SELECT * FROM KPS_Docs WHERE Specialty="%s" ORDER BY Last_Name' %(specialty))
# If there is a city preference
ELSE
result = db.get('SELECT * FROM KPS_Docs WHERE Specialty="%s" AND City="%s" ORDER BY Last_Name' %(specialty,city))
# Check for result being empty
IF result=={}
RETURN 'examples/example6Fail.html'
LastNameList=result["Last_Name"]
FirstNameList=result["First_Name"]
DegreeList=result["Degree"]
AddressList=result["Address"]
CityList=result["City"]
PhoneList=result["Phone"]
RETURN 'examples/example6Return.html'
template = '<TR><TD> %(1)s, %(2)s, %(3)s </TD><TD> %(4)s, %(5)s</TD><TD> %(6)s</TD></TR>' #--------------------------- <CENTER> <HR> <TABLE BGCOLOR="#FFFFFF" BORDER=3 COLS=2 CELLPADDING=3 WIDTH=600> <FONT COLOR="#001177"> <CAPTION><H2>Here is a list of KPS Physicians who specialize in %(specialty)s, located in %(city)s in Clallam County:<H2></CAPTION> <TR><TH>Name</TH><TH>Address</TH><TH>Phone</TH></TR> %(LastNameList,FirstNameList,DegreeList,AddressList,CityList,PhoneList,template)s </FONT> </TABLE> <P> <HR> Click your "Back" button to return to the search page. <HR> </CENTER> |
<HTML> <BODY BGCOLOR="#FFFFFF" LINK="#CC0000" VLINK=#000000 ALINK="#999999"> <CENTER> <HR> <CAPTION><H2>Sorry, there are no KPS Physicians in %(city)s who specialize in %(specialty)s.</H2></CAPTION> <P> Click your "Back" button to try another search. <HR> </CENTER> </BODY> </HTML> |
Doc_ID County Last_Name First_Name Degree Address City Zip Specialty Phone 001 Clallam Addison Dan G MD 828 East 8th Street Port Angeles 98362 FAMILY PRACTICE Unlisted 002 Clallam Bennett John A DO 777 N Fifth Ave Sequim 98382 GENERAL PRACTICE 360-683-7703 003 Clallam Bork David B MD 1102 E Front St Port Angeles 98362 RADIOLOGY 360-452-9729 004 Clallam Bork David B MD 675 N Fifth St Port Angeles 98382 RADIOLOGY 360-983-9699 005 Clallam Bundy Charles A MD 1021 E Caroline Port Angeles 98362 GENERAL SURGERY 360-452-6808 006 Clallam Burk Phillips MD 590 Bogachiel Wy Forks 98331 FAMILY PRACTICE 360-374-6998 007 Clallam Clancy Michael A DO 835 Georgiana Port Angeles 98362 FAMILY PRACTICE 360-457-8534 008 Clallam Corn Joe B MD 625 N Fifth Ave Sequim 98382 INTERNAL MEDICINE 360-683-9473 009 Clallam Craven Robert W MD 777 N 5th Ave Sequim 98382 OTOLARYNGOLOGY 010 Clallam Dalton Marcie M MD 1021 Caroline St Port Angeles 98362 GENERAL SURGERY 360-452-6808 011 Clallam Everett Harold G MD 1205 E Front St Port Angeles 98362 OPHTHALMOLOGY 360-452-9708 012 Clallam Flowers James F MD 1021 Caroline St Port Angeles 98362 GENERAL SURGERY 360-452-6808 013 Clallam Flowers James F MD 777 N Fifth Ave Sequim 98382 GENERAL SURGERY 014 Clallam Johnston David A MD 115 E Railroad Ave Ste 3082 Port Angeles 98362 PSYCHIATRY 360-457-3425 015 Clallam Kriebel Stephen H MD 461 G St SW Forks 98331 FAMILY PRACTICE 360-371-6224 016 Clallam Myers Ronald A MD 2641 Bay St Port Angeles 98362 ANESTHESIOLOGY 360-457-1326 017 Clallam Palmer Robert H MD 930 Caroline St Port Angeles 98362 OBSTETRICS/GYNECOLOGY 360-452-7202 018 Clallam Pisciotta Benjamin P MD 1102 E Front St Port Angeles 98362 RADIOLOGY 360-452-9729 019 Clallam Reis Mark T MD 1136 Water St Port Townsend 98368 ORTHOPEDIC SURGERY 360-385-5635 020 Clallam Roberts Mark W MD 1021 Caroline St Port Angeles 98362 GENERAL SURGERY 360-452-6808 021 Clallam Roberts Mark W MD 777 N Fifth Ave Sequim 98382 GENERAL SURGERY 022 Clallam Schiefelbein Richard A MD 939 Caroline St Port Angeles 98362 INFECTIOUS DISEASE 360-417-7731 023 Clallam Schreiber Eric R MD 1102 E Front St Port Angeles 98362 RADIOLOGY 360-452-9729 024 Clallam Sicuro Paul L MD 1102 E Front St Port Angeles 98362 RADIOLOGY 360-452-9729 025 Clallam Wendel Reed A MD 1021 E Caroline Port Angeles 98362 GENERAL SURGERY 360-452-6808 026 Clallam Ziebarth Joel A MD 939 Caroline Port Angeles 98362 INFECTIOUS DISEASE 360-417-7714 |
| Previous Example | Next Example | Table of Contents |
Updated 2-August-99
|
|
|
|
|
| WebKeystone is a product of Townsend Software, Inc. ©1998 - 2001 Townsend Software, Inc. All rights reserved. |