<HTML>
<HEAD><TITLE>Film Information</TITLE></HEAD>
<BODY>
<H2>Film Information</H2>

<CFTRY>
  <!--- Retrieve Ratings from database --->
  <CFQUERY NAME="GetRatings" DATASOURCE="#REQUEST.DataSource#">
    SELECT RatingID, Rating
    FROM FilmsRatings
    ORDER BY Rating
  </CFQUERY>  

  <!--- Retrieve Films from database --->
  <CFQUERY NAME="GetFilms" DATASOURCE="#REQUEST.DataSource#">
    SELECT FilmID, MovieTitle
    FROM Films
    ORDER BY Films.MovieTitles
  </CFQUERY>
  
  <!--- If any database errors occur during above query, --->
  <CFCATCH TYPE="Database">
    <!--- Let user know that the Films data can't be shown right now --->
    <CFOUTPUT>
      <I>Sorry, we are not able to connect to our real-time database right now,
      because of SQL Error Code <B>#CFCATCH.SqlState#</B>.<BR>
      We're taking care of it, of course. Please check back soon!</I><BR>
    </CFOUTPUT>
    <CFABORT>
  </CFCATCH>
</CFTRY>

<!--- Create self-submitting form --->
<CFFORM ACTION="#CGI.SCRIPT_NAME#" METHOD="Post">
  <!--- If, after all is said and done, we were able to get Film data --->
  <CFIF IsDefined("GetFilms")>
    <!--- Display Film names in a drop-down list --->
    <P>Films:
    <CFSELECT QUERY="GetFilms" NAME="FilmID" 
      VALUE="FilmID" DISPLAY="MovieTitle"/>
  </CFIF>
      
  <!--- If, after all is said and done, we were able to get Ratings data --->
  <CFIF IsDefined("GetRatings")>
    <!--- Display Rating names in a drop-down list --->
    <P>Ratings:
    <CFSELECT QUERY="GetRatings" NAME="RatingID"
      VALUE="RatingID" DISPLAY="Rating"/>
  </CFIF>    

</CFFORM>
     
</BODY>
</HTML>
