home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / sharewar / gdidbpro / data1.cab / Example_Files / projects / default / workweb.scp < prev    next >
Text File  |  2000-05-26  |  8KB  |  304 lines

  1. ##########################################################
  2. # GDIdb demo script (c) 1997 Global Data Industries
  3. # Datasource=workweb.mdb (Access database)
  4. #
  5. # In this advanced example, the script creates a top-level
  6. # page from the contents of the categories table of the
  7. # database, with links to a series of pages listing the
  8. # headings of the jobs stored under each category.
  9. # Each of the job headings are hyperlinked to a html
  10. # document containing the actual job description.
  11. ##########################################################
  12.  
  13.  
  14.  
  15.  
  16. ##########################################################
  17. # Print the information screen
  18.  
  19. &cls
  20. &print("WorkWeb Demo Script")
  21. &print("---------------------------------")
  22.  
  23.  
  24.  
  25.  
  26. ##########################################################
  27. # Name the ODBC datasource to be used.
  28.  
  29. &datasource("Driver={Microsoft Access Driver (*.mdb)};DBQ=workweb.mdb")
  30.  
  31.  
  32.  
  33.  
  34. ##########################################################
  35. # this variable will be used when generating forward/backward
  36. # recordset links
  37.  
  38. &defvar(?var1?)
  39.  
  40.  
  41.  
  42.  
  43. ##########################################################
  44. # Generate the top-level HTML file. 
  45.  
  46. &html("index.html")
  47. {
  48.     <HTML>
  49.     <HEAD>
  50.     <TITLE>Work Web</TITLE>
  51.     </HEAD>
  52.     <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK ALINK=WHITE>
  53.     <FONT FACE="Verdana,Helvetica">
  54.     <IMG SRC="ww1.gif">
  55.     <BR><BR><BR><BR><BR><BR>
  56.     <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%">
  57.     <TR>
  58.     <TD VALIGN=TOP>
  59.     <FONT FACE="Verdana,Helvetica">
  60.     <FONT SIZE="+2">Select a Job Category:</FONT>
  61.     <BR><BR>
  62.     
  63.     # this SQL statement retrieves all of the jobs in the database.
  64.     # the only reason it does this is so that the ?recordsetsize?
  65.     # variable will contain the total number of jobs in the database.
  66.     
  67.     &sql("SELECT * FROM Jobs")
  68.     {
  69.         The Job database currently contains ?recordsetsize?
  70.         vacancies.<BR><BR>
  71.         <FONT SIZE="-1">
  72.         (Updated from database on ?gdidbdate? at ?gdidbtime?)
  73.         </FONT>
  74.         <BR><BR>
  75.     }
  76.     <UL>
  77.     
  78.     # loop through each of the categories, creating category
  79.     # pages (by calling subroutine "jobcategory") and
  80.     # links to them from this page.
  81.  
  82.     &getdata("SELECT * FROM Categories")
  83.     {
  84.         &print("Generating category ?JobCategory?")
  85.         &sql("SELECT * FROM Jobs WHERE (((Jobs.JCatKey)=?JobcatKey?))")
  86.         {
  87.             # do the hyperlink to the job category page
  88.             <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>
  89.  
  90.             # followed by the file to link to
  91.             # (created by subroutine jobcategory)
  92.             &jobcategory
  93.         }
  94.     }
  95.     </UL>
  96.     </FONT>
  97.     </TD>
  98.     <TD WIDTH="45%" VALIGN=TOP><FONT FACE="Verdana,Helvetica">
  99.     <B>This Site</B>  demonstrates the use of GDI's Database
  100.     publishing software. A relational database consisting of
  101.     jobs grouped by job category is merged with the web site
  102.     HTML and passed to the web server <I>automatically.</I> 
  103.     </FONT>
  104.     </TD>
  105.     </TR>
  106.     </TABLE>
  107.     <BR><BR><BR>
  108.     <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%">
  109.     <TR>
  110.     <TD>
  111.     <FONT FACE="Verdana,Helvetica"> 
  112.     <B>System Bullet points:</B>
  113.     <UL>
  114.     <LI> Totally automated publishing of database and spreadsheet data using a dial-up Internet connection.
  115.     <LI> The database does not need to be stored on the web server.
  116.     <LI> No specialist knowledge is required by web site maintainer.
  117.     <LI> Zero administration overhead- Just set the times/days when you
  118.     want to update your web site from your database and forget it!
  119.     </UL>
  120.     </FONT>
  121.     </TD>
  122.     </TR>
  123.     </TABLE>
  124.     <CENTER>
  125.     <FONT FACE="Helvetica">
  126.     <BR><BR>
  127.     <I>Web site design by:</I><BR>
  128.     <A HREF="http://www.gd-ind.com/">GLOBAL DATA INDUSTRIES</A>
  129.     </CENTER>
  130.     </FONT>
  131.     </BODY>
  132.     </HTML>
  133. }
  134.  
  135.  
  136.  
  137.  
  138. ##########################################################
  139. # print the finishing message
  140.  
  141. &msgbox("Finished!",iconinformation)
  142. &cls
  143. &print("Demo website HTML generation complete. Click the Preview HTML button to see the results.")
  144. &print
  145.  
  146. # END OF SCRIPT
  147.  
  148.  
  149.  
  150.  
  151. ##########################################################
  152. # SUBROUTINES
  153.  
  154.  
  155.  
  156.  
  157. ##########################################################
  158. # subroutine jobcategory generates the category pages
  159. # that are linked to from the top-level page 
  160.  
  161. &defsub("jobcategory")
  162. {
  163.  
  164.     # the html file name for each of the job categories is generated
  165.     # by combining the word "cat" with the row number of the job category in
  166.     # the database. since the last &sql function called was to fetch data
  167.     # from the jobs table, we put a [-1] at the end of the variable name
  168.     # ?rownumber? to indicate that it belongs to the previous &sql function's
  169.     # returned data.
  170.  
  171.     &html("cat?rownumber[-1]?.html")
  172.     {
  173.         <HTML>
  174.         <HEAD>
  175.         <TITLE>Jobs List</TITLE>
  176.         </HEAD>
  177.         <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK>
  178.         <FONT FACE="Verdana,Helvetica">
  179.         <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0>
  180.         <TR>
  181.         <TD><IMG SRC="wwbullet1.gif"></TD>
  182.         <TD>
  183.         <FONT SIZE="+3" FACE="Verdana,Helvetica">
  184.         ?JobCategory[-1]?
  185.         </FONT>
  186.         </TD>
  187.         </TR>
  188.         </TABLE>
  189.         <UL><UL>
  190.         
  191.         # if there are jobs under this category, loop through each
  192.         # record creating a job description page (handled by
  193.         # subroutine "jobcontent") and a link from this page
  194.  
  195.         &foreachrow
  196.         {
  197.             # generate the link to the job content file
  198.             <LI><A HREF="jfile?rownumber[-1]?n?rownumber?.html" onMouseover="window.status='View Job (?JobTitle?) details.';return true">?JobTitle?</A><BR>
  199.  
  200.             # followed by the file to link to
  201.             # (created by subroutine jobcontent)
  202.             &jobcontent
  203.         }
  204.  
  205.         # the code between the  characters following the &else() function
  206.         # will be executed if the &getdata() function failed to find any data.
  207.  
  208.         &else
  209.         {
  210.             <P>Sorry, there are no jobs under this category.
  211.         }
  212.         </UL>
  213.         <BR><BR><BR>
  214.         <FONT FACE="Verdana,Helvetica" SIZE="-1">
  215.         <A HREF="index.html"><B>\<-Home</B></A>
  216.         </FONT>
  217.         </UL>
  218.         </FONT>
  219.         </BODY>
  220.         </HTML>
  221.     }
  222. }
  223.  
  224.  
  225.  
  226.  
  227. ##########################################################
  228. # subroutine jobcontent generates the job content pages
  229. # that are linked to from the job category pages
  230.  
  231. &defsub("jobcontent")
  232. {
  233.     # the filename for the job content file is generated by combining
  234.     # the rownumber of the job category (?rownumber[-1]?) with the
  235.     # rownumber of the job.
  236.     # note the 'n' placed between the two rownumber variables, this is
  237.     # required to ensure a unique filename for the page. (think about it... #;-) )
  238.  
  239.     &html("jfile?rownumber[-1]?n?rownumber?.html")
  240.     {
  241.         <HTML>
  242.         <HEAD>
  243.         <TITLE>Job Description</TITLE>
  244.         </HEAD>
  245.         <BODY BACKGROUND="wwbg1.gif" LINK="\#303030" VLINK="\#303030">
  246.         <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0>
  247.         <TR>
  248.         <TD><IMG SRC="wwbullet1.gif"></TD>
  249.         <TD>
  250.         <FONT SIZE="+2" FACE="Verdana,Helvetica">
  251.         ?JobTitle?
  252.         </FONT>
  253.         </TD>
  254.         </TR>
  255.         </TABLE>
  256.         <CENTER>
  257.         <TABLE WIDTH="90%" CELLSPACING=10 BORDER=0>
  258.         <TR>
  259.         <TD>
  260.         <FONT FACE="Verdana,Helvetica" SIZE="+1">Job ref: ?JobNo?</FONT>
  261.         <TT>
  262.         <FONT SIZE="+1"><P>?JobDesc?</FONT>
  263.         </TT>
  264.         <BR><BR><BR>
  265.         <TABLE>
  266.         <TR>
  267.         <TD>
  268.         <FONT FACE="Verdana,Helvetica" SIZE="-1">
  269.         &if(?rownumber?>1)
  270.         {
  271.             &assign(?var1?,?rownumber?-1)
  272.             Prev.<BR>
  273.             <A HREF="jfile?rownumber[-1]?n?var1?.html"><IMG SRC="back.gif" BORDER="0"></A>
  274.         }
  275.         </FONT>
  276.         </TD>
  277.         <TD>
  278.         <FONT FACE="Verdana,Helvetica" SIZE="-1">
  279.         &if(?rownumber?<?recordsetsize?)
  280.         {
  281.             &assign(?var1?,?rownumber?+1)
  282.             Next<BR>
  283.             <A HREF="jfile?rownumber[-1]?n?var1?.html"><IMG SRC="forward.gif" BORDER="0"></A>
  284.         }
  285.         </FONT>
  286.         </TD>
  287.         </TR>
  288.         </TABLE>
  289.         <BR>
  290.         <FONT FACE="Verdana,Helvetica" SIZE="-1">
  291.         <A HREF="index.html"><B>\<-Home</B></A>
  292.         <UL>
  293.         <A HREF="cat?rownumber[-1]?.html"><B>\<-?JobCategory[-1]?</B></A>
  294.         </UL>
  295.         </FONT>
  296.         </TD>
  297.         </TR>
  298.         </TABLE>
  299.         </CENTER>
  300.         </BODY>
  301.         </HTML>
  302.     }
  303. }
  304.