home *** CD-ROM | disk | FTP | other *** search
Wrap
########################################################## # GDIdb demo script (c) 1997 Global Data Industries # Datasource=workweb.mdb (Access database) # # In this advanced example, the script creates a top-level # page from the contents of the categories table of the # database, with links to a series of pages listing the # headings of the jobs stored under each category. # Each of the job headings are hyperlinked to a html # document containing the actual job description. ########################################################## ########################################################## # Print the information screen &cls &print("WorkWeb Demo Script") &print("---------------------------------") ########################################################## # Name the ODBC datasource to be used. &datasource("Driver={Microsoft Access Driver (*.mdb)};DBQ=workweb.mdb") ########################################################## # this variable will be used when generating forward/backward # recordset links &defvar(?var1?) ########################################################## # Generate the top-level HTML file. &html("index.html") { <HTML> <HEAD> <TITLE>Work Web</TITLE> </HEAD> <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK ALINK=WHITE> <FONT FACE="Verdana,Helvetica"> <IMG SRC="ww1.gif"> <BR><BR><BR><BR><BR><BR> <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%"> <TR> <TD VALIGN=TOP> <FONT FACE="Verdana,Helvetica"> <FONT SIZE="+2">Select a Job Category:</FONT> <BR><BR> # this SQL statement retrieves all of the jobs in the database. # the only reason it does this is so that the ?recordsetsize? # variable will contain the total number of jobs in the database. &sql("SELECT * FROM Jobs") { The Job database currently contains ?recordsetsize? vacancies.<BR><BR> <FONT SIZE="-1"> (Updated from database on ?gdidbdate? at ?gdidbtime?) </FONT> <BR><BR> } <UL> # loop through each of the categories, creating category # pages (by calling subroutine "jobcategory") and # links to them from this page. &getdata("SELECT * FROM Categories") { &print("Generating category ?JobCategory?") &sql("SELECT * FROM Jobs WHERE (((Jobs.JCatKey)=?JobcatKey?))") { # do the hyperlink to the job category page <FONT SIZE="-2">(?recordsetsize?)</FONT> <A HREF="cat?rownumber[-1]?.html" onMouseover="window.status='View Jobs in category ?JobCategory[-1]?';return true">?JobCategory[-1]?</A><BR> # followed by the file to link to # (created by subroutine jobcategory) &jobcategory } } </UL> </FONT> </TD> <TD WIDTH="45%" VALIGN=TOP><FONT FACE="Verdana,Helvetica"> <B>This Site</B> demonstrates the use of GDI's Database publishing software. A relational database consisting of jobs grouped by job category is merged with the web site HTML and passed to the web server <I>automatically.</I> </FONT> </TD> </TR> </TABLE> <BR><BR><BR> <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%"> <TR> <TD> <FONT FACE="Verdana,Helvetica"> <B>System Bullet points:</B> <UL> <LI> Totally automated publishing of database and spreadsheet data using a dial-up Internet connection. <LI> The database does not need to be stored on the web server. <LI> No specialist knowledge is required by web site maintainer. <LI> Zero administration overhead- Just set the times/days when you want to update your web site from your database and forget it! </UL> </FONT> </TD> </TR> </TABLE> <CENTER> <FONT FACE="Helvetica"> <BR><BR> <I>Web site design by:</I><BR> <A HREF="http://www.gd-ind.com/">GLOBAL DATA INDUSTRIES</A> </CENTER> </FONT> </BODY> </HTML> } ########################################################## # print the finishing message &msgbox("Finished!",iconinformation) &cls &print("Demo website HTML generation complete. Click the Preview HTML button to see the results.") &print # END OF SCRIPT ########################################################## # SUBROUTINES ########################################################## # subroutine jobcategory generates the category pages # that are linked to from the top-level page &defsub("jobcategory") { # the html file name for each of the job categories is generated # by combining the word "cat" with the row number of the job category in # the database. since the last &sql function called was to fetch data # from the jobs table, we put a [-1] at the end of the variable name # ?rownumber? to indicate that it belongs to the previous &sql function's # returned data. &html("cat?rownumber[-1]?.html") { <HTML> <HEAD> <TITLE>Jobs List</TITLE> </HEAD> <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK> <FONT FACE="Verdana,Helvetica"> <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0> <TR> <TD><IMG SRC="wwbullet1.gif"></TD> <TD> <FONT SIZE="+3" FACE="Verdana,Helvetica"> ?JobCategory[-1]? </FONT> </TD> </TR> </TABLE> <UL><UL> # if there are jobs under this category, loop through each # record creating a job description page (handled by # subroutine "jobcontent") and a link from this page &foreachrow { # generate the link to the job content file <LI><A HREF="jfile?rownumber[-1]?n?rownumber?.html" onMouseover="window.status='View Job (?JobTitle?) details.';return true">?JobTitle?</A><BR> # followed by the file to link to # (created by subroutine jobcontent) &jobcontent } # the code between the characters following the &else() function # will be executed if the &getdata() function failed to find any data. &else { <P>Sorry, there are no jobs under this category. } </UL> <BR><BR><BR> <FONT FACE="Verdana,Helvetica" SIZE="-1"> <A HREF="index.html"><B>\<-Home</B></A> </FONT> </UL> </FONT> </BODY> </HTML> } } ########################################################## # subroutine jobcontent generates the job content pages # that are linked to from the job category pages &defsub("jobcontent") { # the filename for the job content file is generated by combining # the rownumber of the job category (?rownumber[-1]?) with the # rownumber of the job. # note the 'n' placed between the two rownumber variables, this is # required to ensure a unique filename for the page. (think about it... #;-) ) &html("jfile?rownumber[-1]?n?rownumber?.html") { <HTML> <HEAD> <TITLE>Job Description</TITLE> </HEAD> <BODY BACKGROUND="wwbg1.gif" LINK="\#303030" VLINK="\#303030"> <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0> <TR> <TD><IMG SRC="wwbullet1.gif"></TD> <TD> <FONT SIZE="+2" FACE="Verdana,Helvetica"> ?JobTitle? </FONT> </TD> </TR> </TABLE> <CENTER> <TABLE WIDTH="90%" CELLSPACING=10 BORDER=0> <TR> <TD> <FONT FACE="Verdana,Helvetica" SIZE="+1">Job ref: ?JobNo?</FONT> <TT> <FONT SIZE="+1"><P>?JobDesc?</FONT> </TT> <BR><BR><BR> <TABLE> <TR> <TD> <FONT FACE="Verdana,Helvetica" SIZE="-1"> &if(?rownumber?>1) { &assign(?var1?,?rownumber?-1) Prev.<BR> <A HREF="jfile?rownumber[-1]?n?var1?.html"><IMG SRC="back.gif" BORDER="0"></A> } </FONT> </TD> <TD> <FONT FACE="Verdana,Helvetica" SIZE="-1"> &if(?rownumber?<?recordsetsize?) { &assign(?var1?,?rownumber?+1) Next<BR> <A HREF="jfile?rownumber[-1]?n?var1?.html"><IMG SRC="forward.gif" BORDER="0"></A> } </FONT> </TD> </TR> </TABLE> <BR> <FONT FACE="Verdana,Helvetica" SIZE="-1"> <A HREF="index.html"><B>\<-Home</B></A> <UL> <A HREF="cat?rownumber[-1]?.html"><B>\<-?JobCategory[-1]?</B></A> </UL> </FONT> </TD> </TR> </TABLE> </CENTER> </BODY> </HTML> } }