Sunday, December 5, 2010

Re: Help with multiple foreachs

That is actually what I have with the nested foreachs but I still get
undefined variable ticket. Event HasMany Venues HasMany Tickets. The
"Related Venues" functionality (as generated by bake) is
$event['Venue']. The undefined variable ticket is coming in on the
line "echo $ticket['price']". This is a very bizarre issue. I can
display echo pr($venue[['Ticket']) and see the [0] ... and [1] ....
tickets that I'm expecting to see what the arrays are not getting
assigned to $ticket in the second foreach loop.

Thanks,
Brian

On Dec 5, 2:37 pm, Bart <bart.gloudem...@gmail.com> wrote:
> Your data structure is not completely clear, but I presume the ticket-
> loop is nested in the venue-loop because a Venue has multiple tickets.
> In that case the base-node for your ticket loop should be $venue, and
> not $event['Venue'].
> Like this:
>
> foreach($event['Venue'] as $venue){
>   foreach($venue['Ticket'] as $ticket){
>     echo $ticket['price'];
>   }
>
> }
>
> On Dec 5, 4:50 pm, lirc201 <brian.e.lave...@gmail.com> wrote:
>
> > I've been looking at this way too long and need a little push.  I'm
> > trying to display all of the available tickets for all venues that are
> > part of a selected event.  I have the recursion correct for my model
> > call.  My first foreach loop
>
> > foreach $event['Venue'] as $venue
>
> > this displays all of the information for each venue
>
> > the next nested foreach loop is where I'm having difficulty trying to
> > get correct.
>
> > I've played with this foreach ($event['Venue'] as $ticket) but keep
> > getting an ... undefined variable ticket ... when I try to echo
> > $ticket['displayName'], however I see the results I want if I debug
> > display $event['Venue'][0]['Ticket']
>
> > I'm using cake 1.3.6
>
> > Thanks,
> > Brian

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate