The <a> element in the inner loop only references the question variable, 
which is set in the outer loop. Perhaps instead of question, you menat to 
put correct_questions[record].

Anthony

On Wednesday, October 15, 2014 7:03:39 PM UTC-4, LoveWeb2py wrote:
>
> Hello.... I'm trying to create a menu for users who have already answered 
> a question correctly. The questions are stored in the database, but for 
> some reason my double for loop displays 10 of the same question. When I try 
> my logic using python web2py.py -S myapp -M the logic works fine, however 
> when I transfer it to the view it shows something like this:
>
> Menu item 1
> Menu item 1
> Menu item 1
> Menu item 1
> Menu item 1
> Menu item 1
> Menu item 2
> Menu item 2
> Menu item 2
> Menu item 2
> Menu item 2
>
> and so on and so on... I'm guessing it has something to do with my for 
> loop, but I've been stuck on this for hours. Any help would be greatly 
> appreciated. Thanks!
>
>
> code here:
>
>>             <ul>{{try:}}
>>
>>                     {{for question in all_questions:}}
>>
>>                 {{for record in correct_questions:}}
>>
>>                     {{if question['difficulty']=='subject1' and 
>>> correct_questions[record]['question'] != question['id']:}}
>>
>>                     <li class="padded"><a href="{{=URL('challenges', 
>>> vars={'chal':question['id']})}}">{{=question['title']}} 
>>> ({{=question['points']}} pts) </a></li>
>>
>>                     {{pass}}
>>
>>                     {{pass}}
>>
>>                     {{else:}}
>>
>>                 
>>
>>                 <li class="padded"><i class="fa fa-check icon-small"></i> 
>>> <a href="{{=URL('challenges', vars={'chal':question['id']})}}", 
>>> style="color:gray;">{{=question['title']}} ({{=question['points']}} pts) 
>>> </a></li>
>>
>>                 {{pass}}
>>
>>                     {{except:}}
>>
>>                 {{pass}}
>>
>>  
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to