I've tried every variation of ' ' that makes sense and the syntax is
identical to syntax that returns info from the first array (recipe) of
the multideminsional array.
The difference is that recipe is (see above) declared in the
controller but ingredient isn't - because I don't know how.
On Jun 10, 8:55 am, Smelly_Eddie <[EMAIL PROTECTED]> wrote:
> Constant means variables like FILE_PATH. Notice no $.
>
> I must believe that PHP is treating Ingredient as a constant that it
> cannot find.
>
> Since it cannot load that array, it also will report that the index
> 'ingredientname' cant be found. Its like finding the steering wheel
> for a car that you can see.
>
> Adding ' ' will let php engine know its a string, not a constant.
> which should then load the array, and find the index.
>
> You said the debug will print the array structure correctly, so your
> controller must be working.
>
> It will take 10 seconds to try, just do it.
>
> On Jun 10, 5:52 am, Peter54 <[EMAIL PROTECTED]> wrote:
>
> > In fact it's exactly the same syntax that works for the first array
> > (Recipe):
>
> > $todays_recipe[Recipe]['RecipeName'] - allows me to access array
> > items
> > $todays_recipe[Ingredient]['IngredientName'] give me undefined
> > constand and undefined index [IngredientName]
>
> > On Jun 10, 2:28 am, Simon COURTOIS <[EMAIL PROTECTED]> wrote:
>
> > > Peter54 wrote On 06/10/2008 02:05 AM:
>
> > > > First off I'm not just new to Cake I'm new to programing. I can get my
> > > > head around relatively simple stuff and can generalize once I have a
> > > > concept but even though I know this is either obvious, or been
> > > > answered a thousand times I can't see it anywhere or figure out how it
> > > > works.
>
> > > > I have a two tables Recipes and Ingredients and a JoinTable
> > > > Ingredients_Recipes that contains the foreign keys plus some other
> > > > data.
>
> > > > In my controller I have the following code:
> > > > $recipe = $this->Recipe->find(array('ShowDate'=>$today));
> > > > $this->set('todays_recipe', $recipe);
>
> > > > Which in debug send all the relevant elements of the all tables to the
> > > > view:
> > > > $___dataForView = array(
> > > > "todays_recipe" => array(
> > > > "Recipe" => array(
> > > > "recipe_id" => "20",
> > > > "RecipeName" => "Banana Bread",
> > > > ),
> > > > "Ingredient" => array(
> > > > array(
> > > > "ingredient_id" => "1",
> > > > "IngredientName" => "Eggs",
> > > > "IngredientsRecipe" => array(
> > > > "id" => "1",
> > > > "recipe_id" => "20",
> > > > "ingredient_id" => "1",
> > > > "Amount" => "2",
> > > > )
>
> > > > In my view code
> > > > echo @"The dinner for $today is {$todays_recipe[Recipe]['RecipeName']}
> > > > ';
>
> > > > and I can generalize that to display anyting in the recipe array ie
> > > > serves = $todays_recipe[Recipe]['Serves']";
>
> > > > But when I try this with the Ingredients using - echo "this
> > > > {$today_recipe[Ingredient]['IngredientName']}";
>
> > > > I get undefined constants or undefined variables.
>
> > > > I assume I have to declare the ingredients array in the controller or
> > > > assign it to a variable but how? I don't know and at the risk of
> > > > appearing stupid or irritating I thought I'd ask.
>
> > > Hi,
>
> > > Isn't it a quote problem ? U do $today_recipe[Ingredient] instead of
> > > $today_recipe['Ingredient'].
> > > I hope it's because of it ;)
>
> > > --
> > > Simon COURTOIS
> > > {EPITECH.} tek4 | (LINAGORA) Developer | [ADITAM] Project Manager
> > > 10, rue Brillat-Savarin 75013 Paris | 01 45 42 72 30 - 06 72 44 67
> > > 81http://www.happynoff.fr
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---