<!--- If form is being submitted, commit changes to the database --->
<CFIF CGI.REQUEST_METHOD is "Post">
  <CFGRIDUPDATE
    DATASOURCE="ows"
    TABLENAME="Actors"
    GRID="ActorGrid"
    KEYONLY="No">
</CFIF>

<!--- Get list of films from database --->
<!--- Include a column of blank values called ImagePath --->
<CFQUERY NAME="GetFilms" DATASOURCE="ows">
  SELECT FilmID, MovieTitle, AmountBudgeted, '' AS ImagePath 
  FROM Films
  ORDER BY MovieTitle
</CFQUERY>

<!--- For each film, check to see if we have a image for it --->
<CFLOOP QUERY="GetFilms">
  <!--- This is the relative URL path for the image --->
  <CFSET TestImagePath = "../images/f#GetFilms.FilmID#.gif">
  <!--- If the image file actually exists on this server's drive --->
  <CFIF FileExists(ExpandPath(TestImagePath))>
    <!--- Set the ImagePath column of the current row --->
    <CFSET GetFilms.ImagePath[CurrentRow] = TestImagePath>
  </CFIF>
</CFLOOP>

<HTML>
<HEAD><TITLE>Orange Whip Studios Films</TITLE></HEAD>
<BODY>
<H2>Orange Whip Studios Films</H2>

<!--- Data entry form --->
<CFFORM ACTION="#CGI.SCRIPT_NAME#" METHOD="Post">

  <!--- Grid control for expenses --->
  <CFGRID 
    NAME="ActorGrid" 
    QUERY="GetFilms"
    WIDTH="525"
    HEIGHT="400"
    ROWHEADERS="No"
    ROWHEIGHT="130"
    COLHEADERBOLD="Yes"
    COLHEADERALIGN="Center"
    SELECTMODE="EDIT">
    <!--- Hidden column for FilmID - does not actually get displayed --->
    <CFGRIDCOLUMN 
      NAME="FilmID"
      DISPLAY="No">
    <!--- Column for film's title --->
    <CFGRIDCOLUMN 
      NAME="MovieTitle"
      HEADER="Film Title"
      WIDTH="200">
    <!--- Column for film's budget --->
    <CFGRIDCOLUMN 
      NAME="AmountBudgeted"
      HEADER="Budget"
      WIDTH="100"
      NUMBERFORMAT="999,999,999,999.">
    <!--- Column for film's publicity image, if any --->
    <CFGRIDCOLUMN 
      TYPE="Image"
      NAME="ImagePath"
      HEADER="Image"
      WIDTH="200">

  </CFGRID>

  <P><INPUT TYPE="Submit" VALUE="Submit Changes">
</CFFORM>

</BODY>
</HTML>