I have tried everything and read a lot about outer joins. And this is what I get-
Here is the complete code with the output at the bottom:
<cfparam name="URL.recNo" default="1">
<cfparam name="URL.recIng" default="0">
<cfset displayRecordNumber=URL.recNo>
<cfset nextRecipe=displayRecordNumber+1>
<cfset previousRecipe=displayRecordNumber-1>
<cfset displayRecipeIng=URL.recIng+1>
<!---QUERY DATABASE TO OUTPUT SELECT INFORMATION--->
<cfquery name="getRecipes">
SELECT DISTINCT Ingredients.IngName,
Measurements.MeasurementName, RecipeIngredients.Amount,
Recipes.RecipeID, Recipes.RecipeName, Recipes.Directions,
Recipes.Notes FROM Recipes, RecipeClass, Measurements,
RecipeIngredients, Ingredients
WHERE RecipeIngredients.RecipeID=Recipes.RecipeID AND
Ingredients.IngID=RecipeIngredients.IngID AND
Measurements.MeasurementID=RecipeIngredients.MeasurementID
AND RecipeClass.RecipeClassID=Recipes.RecipeClassID
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<html>
<head>
<title>Recipe Details</title>
<style>
TD {
font-family : "Trebuchet MS";
}
H3 {
font-family : "Trebuchet MS";
}
</style>
</head>
<body bgcolor="#99CCFF">
<hr align="center" color="Black" width="300">
<h3 align="center">Recipe Details Intranet Application</h3>
<hr align="center" color="Black" width="300">
<!---LOOPS TO CYCLE THROUGH EACH RECIPE'S
INFORMATION--->
<cfloop query="getRecipes" startrow="#displayRecordNumber#"
endrow="#displayRecordNumber#">
<table align="center" border="1" bordercolor="Black"
width="800">
<tr>
<td >
<!---OUTPUT STATEMENTS TO DISPLAY RECIPES'
INFORMATION--->
<cfloop index="IngName" list="#IngName#">
<cfoutput>#Amount# #MeasurementName# #IngNa
me#</cfoutput></td></cfloop><br><br>
<cfoutput><td><b>#RecipeName#</b><br><br>
#Directions#<br><br>
#Notes#<br><br></td></cfoutput>
</td>
</tr>
</cfloop>
</table>
Here is what the output looks like
(Ingredients)1 box 7 oz. Moist Deluxe Butter Recipe cake mix
"no oher ingredients"
(Recipe Name)Apple Tea Cake
(Directions)1. Preheat oven to moderate 350F. Brush a shallow 8 inch round cake pan with melted butter or oil. Line base with waxed paper; grease paper. 2. Reserve 2 tablespoons of the tea cake mix for topping. Place the remaining contents of cake mix into small mixing bowl with butter, egg, juice and apple. Using electric beaters, beat ingredients together on low speed for 2 minutes or until mixture is smooth. Spread mixture over base of prepared pan; smooth surface. 3. Place cinnamon, sugar, reserved cake mix, coconut and extra butter in small mixing bowl. Using fingertips, rub butter into mixture for 1 minute or until mixture is a coarse, crumbly texture; add almonds. Sprinkle the mixture over cake batter, bake 30 minutes or until skew comes out clean when inserted in center of cake. Leave cake in pan 5 minutes before turning onto wire rack to cool. Dust with confectioners' sugar and serve warm or cold with custard sauce or cream.
Problems Looping Through A Db ItemOnly 1 ingredient displays in the loop
Page 1 of 1
7 Replies - 2630 Views - Last Post: 05 January 2005 - 07:47 AM
Replies To: Problems Looping Through A Db Item
#2
Re: Problems Looping Through A Db Item
Posted 08 December 2004 - 10:42 AM
Is it a ColdFusion loop problem, or a query problem? run that query on the command line, and see what it brings back for ingredients. Your 'WHERE' clause has a lot of AND conditions, and so may be limiting the results.
#3
Re: Problems Looping Through A Db Item
Posted 08 December 2004 - 10:59 AM
also, what is the output supposed to be compared to what your getting now?
#4
Re: Problems Looping Through A Db Item
Posted 08 December 2004 - 11:07 AM
The output is supposed to be exactly what it is at the bottom of the code, except it is supposed to show all of the ingredients for that recipe.
EX: 1 box 7 oz. Moist Deluxe Butter Recipe cake mix
2 eggs
1/2 cup sugar, etc.
EX: 1 box 7 oz. Moist Deluxe Butter Recipe cake mix
2 eggs
1/2 cup sugar, etc.
#5
Re: Problems Looping Through A Db Item
Posted 09 December 2004 - 08:37 AM
In the debugging information, how many records does your query return, also, if you do a cfdump what does the query look like?
#6
Re: Problems Looping Through A Db Item
Posted 09 December 2004 - 02:20 PM
Skyhawk,
When I use the cfdump tag, it returns over 200 records, each recipe ingredient with directions for each specific cake. What I am trying to do is return each recipe ingredient specific to each recipe with the recipe's directions. It is something wrong with displaying a list of ingredients for each recipe, but I don't know what?
When I use the cfdump tag, it returns over 200 records, each recipe ingredient with directions for each specific cake. What I am trying to do is return each recipe ingredient specific to each recipe with the recipe's directions. It is something wrong with displaying a list of ingredients for each recipe, but I don't know what?
#7
Re: Problems Looping Through A Db Item
Posted 09 December 2004 - 02:26 PM
Hmmm, I'm in PHP mode right now, but I'll try and figure out what's causing it later.
If I were to do this, and I might be totally wrong here with the way you are doing your code, but I would pull back the recipe AND ingredients in 1 query (which I think you are already doing), then I would use a <cfoutput query="getRecipes" group="RecipeID"> which will group the output by the recipe then display all the ingredients under it.
If I were to do this, and I might be totally wrong here with the way you are doing your code, but I would pull back the recipe AND ingredients in 1 query (which I think you are already doing), then I would use a <cfoutput query="getRecipes" group="RecipeID"> which will group the output by the recipe then display all the ingredients under it.
#8
Re: Problems Looping Through A Db Item
Posted 05 January 2005 - 07:47 AM
i would not use the loop. like skyhawk stated
<cfoutput query="querynamehere"> should take care of all your needs ... or move the cfloop inside the cfoutputs. that may fix it ... but the first recomendation should work
<cfoutput query="querynamehere"> should take care of all your needs ... or move the cfloop inside the cfoutputs. that may fix it ... but the first recomendation should work
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|