★ wanayoo — archive 1999 http://www.webtechniques.com/sourcecode/1997/11/note/chalnick.lstNouvelle recherche | Portail wanayoo

 
| home | current issue | archives | source code | events | demo express | search | editorial calendar | advertising | customer service | author guidelines | jobs | about

S O U R C E   C O D E / 1997 / 11 / note / chalnick.lst

"Linking Web Databases with Cold Fusion"
By Leon Chalnick
Web Techniques, November 1997

Web Techniques grants permission to use these listings for private or 
commercial use provided that credit to Web Techniques and the author is 
maintained within the comments of the source. For questions, contact
editors@web-techniques.com.

LAB NOTE

LISTING ONE

<CFQUERY 
   DATASOURCE="CatalogData"
   NAME="MakeCatalog"
>
   SELECT DISTINCTROW Listings.ItemNbr, Listings.Category, 
     Listings.Title, Artists.GroupName, Producers.ProducerOrg, 
Listings.Description
   FROM (Listings INNER JOIN Artists ON Listings.ArtistID = 
Artists.ArtistID) 
      INNER JOIN Producers ON Listings.ProducerID = 
Producers.ProducerID 
   ORDER BY Listings.ItemNbr
</CFQUERY>

<HTML>
<HEAD>
   <TITLE>MondoMIDIŃCatalog Listing</TITLE>
</HEAD>

<BODY BGCOLOR="White">
<IMG SRC="/old?u=http%3A%2F%2Fwww.webtechniques.com%2Fsourcecode%2F1997%2F11%2Fg%2FMondoLogo.gif&y=1999" ALIGN="right" WIDTH=306 
HEIGHT=36 ALT="MondoMIDI Logo">
<BR CLEAR="right">
<H2>Comprehensive Listing</H2>
<TABLE WIDTH="100%" BORDER=1>
<TR>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Category</FONT></TH>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Title</FONT></TH>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Artist</FONT></TH>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Producer</FONT></TH>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Description</FONT></TH>
</TR>
<CFOUTPUT QUERY="MakeCatalog">
   <TR VALIGN="top">
      <TD>#Category#</TD>
      <TD><STRONG>#Title#</STRONG></TD>
      <TD>#GroupName#</TD>
      <TD>#ProducerOrg#</TD>
      <TD>#Description#</TD>
   </TR>
</CFOUTPUT>
</TABLE>
</BODY>
</HTML>



LISTING TWO



<CFQUERY 
   DATASOURCE="CatalogData"
   NAME="MakeCatalog"
>
   SELECT DISTINCTROW Listings.ItemNbr, Listings.Category, 
Categories.SortPosition,
     Listings.Title, Artists.GroupName, Producers.ProducerOrg, 
Listings.Description
   FROM ((Listings INNER JOIN Artists ON Listings.ArtistID = 
Artists.ArtistID) 
      INNER JOIN Producers ON Listings.ProducerID = 
Producers.ProducerID) 
      INNER JOIN Categories ON Listings.Category = Categories.Category
   ORDER BY Categories.SortPosition, Listings.Title
</CFQUERY>

<HTML>
<HEAD>
   <TITLE>MondoMIDIŃCatalog Listing</TITLE>
</HEAD>

<BODY BGCOLOR="White">
<IMG SRC="/old?u=http%3A%2F%2Fwww.webtechniques.com%2Fsourcecode%2F1997%2F11%2Fg%2FMondoLogo.gif&y=1999" ALIGN="right" WIDTH=306 
HEIGHT=36 ALT="MondoMIDI Logo">
<BR CLEAR="right">
<H2>Comprehensive Listing</H2>
<TABLE WIDTH="100%" BORDER=1>
<TR>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Title</FONT></TH>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Artist</FONT></TH>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Producer</FONT></TH>
   <TH BGCOLOR="sliver" ALIGN="bottom"><FONT 
COLOR="white">Description</FONT></TH>
</TR>
<CFOUTPUT QUERY="MakeCatalog" GROUP="SortPosition">
   <TR VALIGN="bottom">
      <TH COLSPAN=5 BGCOLOR="Gray">
         <FONT SIZE=4 COLOR="White">#Category#</FONT>
      </TH>
   </TR>
   <CFOUTPUT>
      <TR VALIGN="top">
         <TD><STRONG>#Title#</STRONG></TD>
         <TD>#GroupName#</TD>
         <TD>#ProducerOrg#</TD>
         <TD>#Description#</TD>
      </TR>
   </CFOUTPUT>
</CFOUTPUT>
</TABLE>
</BODY>
</HTML>



LISTING THREE



<HTML>
<HEAD>
   <TITLE>Upload MIDI File</TITLE>
</HEAD>
<BODY BGCOLOR="White">

<H3>Specify Upload File</H3>
Please specify the MIDI file to upload. After you've successfully 
uploaded the
file, you will use another form to describe it.
<P>
<HR>
<P>
<TABLE BORDER=1 BGCOLOR="Silver">
<TR>
<TD BGCOLOR="Silver">

<CFFORM 
   NAME="UploadForm"
   ACTION="/old?u=http%3A%2F%2Fwww.webtechniques.com%2Fsourcecode%2F1997%2F11%2Fnote%2FUploadAndDefine.cfm&y=1999" 
   ENCTYPE="multipart/form-data" 
   METHOD="post"
>

<TABLE>
<TR>
   <TH ALIGN="center" COLSPAN=2 BGCOLOR="DarkBlue">
      <FONT COLOR="#fffff1">Please select the file to be uploaded
   </TH>
</TR>
<TR>
   <TH ALIGN="right">
      Upload file:
   </TH>
   <TD ALIGN="left">
      <INPUT
         NAME="UserFileName"
         SIZE=40
         TYPE="file"
      >
   </TD>
</TR>
<TR VALIGN="top" ALIGN="center">
   <TD COLSPAN=2>
      <INPUT TYPE="submit" VALUE="Upload File">
   </TD>
</TR>
</TABLE>
</CFFORM>

</TD>
</TR>
</TABLE>
</BODY>
</HTML>



LISTING FOUR



<!--- Make sure user specified the name of the file to upload --->
<CFIF Form.UserFileName is "">
   <CFSET ErrorMsg = "You must specify a valid file name to upload 
from your computer|">
   <CFINCLUDE TEMPLATE="ShowError.cfm">
   <CFABORT>
</CFIF>

<!--- Now, try uploading the file --->
<CFFILE ACTION="/old?u=http%3A%2F%2Fwww.webtechniques.com%2Fsourcecode%2F1997%2F11%2Fnote%2FUPLOAD&y=1999"
   FILEFIELD="UserFileName"
   DESTINATION="c:\temp\"
   NAMECONFLICT="Skip"
>

<!--- Check to see if file was saved properly --->
<CFIF File.FileWasSaved is "No">
   <CFSET ErrorMsg = "The file you specified could not be uploaded 
and saved|">
   <CFIF File.FileExisted is "Yes">
      <CFSET ErrorMsg = #ErrorMsg# & "A file with this name already 
exists on 
                                                                      
the server|">
   <CFELSE>
      <CFSET ErrorMsg = #ErrorMsg# & "There is a problem with the 
specified file|">
   </CFIF>
   <CFINCLUDE TEMPLATE="ShowError.cfm">
   <CFABORT>
</CFIF>

<!--- If we made it here, then file was uploaded ok --->

<!--- Get all artist data --->
<CFQUERY
   DATASOURCE="CatalogData"
   NAME="GetArtists"
>
   SELECT DISTINCTROW ArtistID, GroupName
   FROM Artists
</CFQUERY>

<!--- Get all musical categories --->
<CFQUERY
   DATASOURCE="CatalogData"
   NAME="GetCategories"
>
   SELECT Category
   FROM Categories
</CFQUERY>

<!--- Get all producers --->
<CFQUERY
   DATASOURCE="CatalogData"
   NAME="GetProducers"
>
   SELECT DISTINCTROW Producers.ProducerID, 
      IIf(ProducerFName Is Null, ProducerOrg, ProducerOrg +', '+ 
ProducerFName +' 
                                                              '+ 
ProducerLName )
         AS Producer
   FROM Producers
</CFQUERY>

<HTML>
<HEAD>
   <SCRIPT TYPE="JavaScript">
   <!-- Hide the code from all well-behaved non-JS browsers
      
      // NewItem is used to process the 'New...' button. This is used
      // to call another template. The template name is passed as a
      // paramter
      function NewItem( strTemplate ) {

         top.location.href = /old?u=http%3A%2F%2Fwww.webtechniques.com%2Fsourcecode%2F1997%2F11%2Fnote%2FstrTemplate&y=1999
         return true;
      }

   // Un-hide the JavaScript code -->
   </SCRIPT>

   <TITLE>Make a Listing</TITLE>
</HEAD>
<BODY BGCOLOR="white">

<H3>File <CFOUTPUT>#File.ClientFile#</CFOUTPUT> Successfully 
Uploaded</H3>
Please use the following form to describe the 
<CFOUTPUT>#File.ClientFile#</CFOUTPUT> file.
<P>
<HR>
<P>
<TABLE BORDER=1>
<TR>
<TD BGCOLOR="Silver">

<CFFORM
   NAME="Listing"
   ACTION="/old?u=http%3A%2F%2Fwww.webtechniques.com%2Fsourcecode%2F1997%2F11%2Fnote%2FPostListing.cfm&y=1999"
   METHOD="post"
>

<!--- Save the name of the MIDI file specified in the calling form --->
<CFOUTPUT>
<INPUT TYPE="hidden" NAME="FileName" VALUE="#File.ClientFile#">
</CFOUTPUT>

<TABLE>
<TR ALIGN="center">
   <TH COLSPAN=3 BGCOLOR="DarkBlue">
      <FONT COLOR="#fffff1">Song Info</FONT>
   </TH>
</TR>
<TR VALIGN="top">
   <TH ALIGN="right" >
      Song Title:
   </TH>
   <TD ALIGN="left" COLSPAN=2>
      <CFINPUT
         NAME="Title"
         REQUIRED="Yes"
         MESSAGE="You must enter a song title"
         SIZE=30
         MAXLENGTH=35
      >
   </TD>
</TR>
<TR VALIGN="top">
   <TH ALIGN="right" >
      Select an artist:
   </TH>
   <TD ALIGN="left">
      <CFSELECT
         NAME="ArtistID"
         SIZE=1            
         REQUIRED="Yes"
         MESSAGE="You must select an artist or add a new artist"
         QUERY="GetArtists"
         VALUE="ArtistID"
         DISPLAY="GroupName"
      >
      </CFSELECT>
   </TD>
   <TD ALIGN="right">
      <INPUT TYPE="button" 
         NAME="NewArtist" 
         VALUE="New..." 
         onClick="NewItem('Stub.htm');"
      >
   </TD>
</TR>

<!--- Producer info --->
<TR VALIGN="top">
   <TH ALIGN="right" >
      Select an producer:
   </TH>
   <TD ALIGN="left">
      <CFSELECT
         NAME="ProducerID"
         SIZE=1            
         REQUIRED="Yes"
         MESSAGE="You must select a producer or add a new producer"
         QUERY="GetProducers"
         VALUE="ProducerID"
         DISPLAY="Producer"
      >
      </CFSELECT>
   </TD>
   <TD ALIGN="right">
      <INPUT TYPE="button" 
         NAME="NewProducer" 
         VALUE="New..." 
         onClick="NewItem('Stub.htm');"
      >
   </TD>
</TR>

<!--- Category info --->
<TR VALIGN="top">
   <TH ALIGN="right" >
      Select an category:
   </TH>
   <TD ALIGN="left">
      <CFSELECT
         NAME="Category"
         SIZE=1            
         REQUIRED="Yes"
         MESSAGE="You must select a category or add a new category"
         QUERY="GetCategories"
         VALUE="Category"
         DISPLAY="Category"
      >
      </CFSELECT>
   </TD>
   <TD ALIGN="right">
      <INPUT TYPE="button" 
         NAME="NewCategory" 
         VALUE="New..." 
         onClick="NewItem('Stub.htm');"
      >
   </TD>
</TR>

<!--- Song Description --->
<TR VALIGN="top">
   <TH ALIGN="right" >
      Description:
   </TH>
   <TD COLSPAN=2 ALIGN="left">
      <TEXTAREA
         NAME="Description"
         ROWS=3
         COLS=40
         WRAP="virtual"
      ></TEXTAREA>
   </TD>
</TR>
<TR VALIGN="top" ALIGN="center" >
   <TD COLSPAN=3>
      <INPUT TYPE="submit" VALUE="Save">
   </TD>
</TR>
</TABLE>

</CFFORM>

</TD>
</TR>
</TABLE>

</BODY>
</HTML>



LISTING FIVE



<HTML>
<HEAD>
   <TITLE>Form Entries Incomplete or Invalid</TITLE>
</HEAD>
<BODY BGCOLOR="White">
<HR>
<H3>Form Entries Incomplete or Invalid</H3>
One or more problems exist with the data you have entered.
<UL>
   <CFLOOP
      LIST="#ErrorMsg#"
      INDEX="ii"
      DELIMITERS="|"
   >
      <LI><CFOUTPUT>#ii#</CFOUTPUT><BR>
   </CFLOOP>
</UL>
Use the <I>Back</I> button on your web browser to return to the 
previous page and correct the listed problems.
<P>
<HR>
</BODY>
</HTML> 



LISTING SIX



<!--- Write form entries into Listings table --->
<CFQUERY
   DATASOURCE="CatalogData"
   NAME="InsertListing"
>
   INSERT INTO Listings ( Title, ArtistID, ProducerID, Category, 
                                         FileName, Description )
   VALUES ( '#Form.Title#', #Form.ArtistID#, #Form.ProducerID#, 
            '#Form.Category#', '#Form.FileName#', '#Form.Description#' 
)
</CFQUERY>
   
<!--- Display link to comprehensive listings page --->
<HTML>
<HEAD>
   <TITLE>Thank You For Submitting Your MIDI File</TITLE>
</HEAD>
<BODY BGCOLOR="white">
<H2>Thank You For Submitting Your MIDI File</H2>
<CFOUTPUT>#FileName#</CFOUTPUT> was successfully uploaded and 
saved.
Your entry was made in the database and is now available on the 
<A HREF="/old?u=http%3A%2F%2Fwww.webtechniques.com%2Fsourcecode%2F1997%2F11%2Fnote%2FCatalog.cfm&y=1999">Comprehensive Listing</A> page.
</BODY>
</HTML>



| home | current issue | archives | source code | demo express | events | search | editorial calendar | advertising | customer service | author guidelines | jobs | about




Entire contents copyright 1996-2000 CMP Media Inc.
Read our privacy policy.