Don't understand what book is telling me...

cgacfox's picture

She has: 15 posts

Joined: May 2004

I am doing some examples in the book "Macromedia ColdFusion MX Web Application construction Kit" by Ben Forta to get used to doing some things with my DVD database. There is a section on building a form to update a record. In order to update the record the id number must be present. There is code to check for the presence of the id number but the author said to append it. Here is part of the code for the form:

You did not specify the FilmID

SELECT FilmID, MovieTitle, PitchText,
AmountBudgeted, RatingID,
Summary, ImageName, DateInTheaters
FROM Films
WHERE FilmID=#URL.FilmID#

SELECT RatingID, Rating
FROM FilmsRatings
ORDER BY RatingID

The author states to "Be sure to append the FilmID--for example, ?FilmID=13--as a URL parameter." I have tried playing with this everywhere the URL is listed and keep coming up with errors. Where does the author want this appended FilmID placed? I am practicing before I tweak the code to fit my update form for my DVD database and am completely stuck!! Please help! Thanks.

Cori Confused

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

http://www.yourdomain.com/yourpage.cfm?FilmID=13 -- when you actually browse to the page...

cgacfox's picture

She has: 15 posts

Joined: May 2004

Suzanne:
I am not sure what you are saying here. I tried appending the CFFORM action and that didn't work. I have some more detail from the book. Please see if this sheds some light on what I am confused about because it doesn't do it for me.

"To populate a form with data to be updated, you must first retrieve that row from the table. Therefore, you must specify a FilmID to use this template. Without it, ColdFusion would not know which row to retrieve. To ensure that the FilmID is passed, the first thing you do is check for the existence of the FilmID parameter. The following code returns TRUE only if FilmID was not passed, in which case an error message is sent back to the user and template processing is halted with the tag:

Without the tag, ColdFusion continues processing the template. An error message is generated when the statement is processed because the WHERE clause WHERE FilmID = #URL.FilmID# references a nonexistent field.

The first tag retrieves the row to be edited, and the passed URL is used to the WHERE clause to retrieve the appropriate row"(Forta, p.327).

From these paragraphs, I would think that the appended FilmID would be the first instance of it in the "if" statement, but it doesn't work. I wonder if I should e-mail him and ask him about this!

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Okay, there are a few ways to send the information.

In an HTML form, you'd add a hidden field usually --

Or you can append it to the query string for a hyperlink -- click here for FieldID 13

Does that help? Without passing this information in either of these methods (POST and GET, respectively), the script cannot work.

cgacfox's picture

She has: 15 posts

Joined: May 2004

Thanks for the help, Suzanne. I ended up trashing what I had built so far and went with Mr. Forta's creation at the end of chapter 13 in his book. I tweaked it to accomodate my fields in my database. So far everything works well except my checkbox fields. When I click on the edit button for a certain movie, it sends the infomation to a page that populates all the information but the checkboxes that are checked in the database don't show up checked on the form. I am wondering how to correct this. Here is a snippit of the code used for the page:

This first part is at the top of the page.

Copy Flag:

This is how the fields are set up. I know that I had to tweak the other form that I was using for checkboxes and their values but I just went with what Mr. Forta had. I would like to be able to see the checks in the checkboxes when I edit the DVD so that I know I entered it with the correct checkboxes checked! The fields in the database are Yes/No boxes and are not required. It looks like I have to do something with the code to get this to work. Any suggestions?

Cori

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Honestly, I don't use ColdFusion -- it seems like in making it easier they fail to explain the basics to you...

Basically you would test to see if these checkboxes are selected or not, and if they are, add additional HTML to indicate that. I don't know how ColdFusion handles conditional tests.

vexcom's picture

He has: 21 posts

Joined: Jul 2004

I think your trying to show certian boxes checked on your results page in which case you want to do this:

checked
>

This wil check your boxes.. so to speak Sticking out tongue

- Wesley E. Warren, CEO - Vexcom Advanced Systems Development
Realty-SEO Real Estate Marketing
Freelance Graphic and Web Designers Directory - Join Free
"All limitations are self imposed" ~ Malaclypse The Younger

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.