Support Forums

Old 05-03-2006, 08:44 AM   #1
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default Can anyone help with this smarty loop

I think I have had this problem and just cant remember where i found the answer.

What is happening is I am trying to loop an <option>

here is the code I have used
PHP Code:
<form action="addplayer.php" name="addplayer" method="get" 
<
select id="selectteam" name="selectteam">
<
option value="">Select a Team</option>
{
section name=select loop=$teams}
<
option value="{$teams[select].TID}">{$teams[select].name}</option>
{/
section}
</
select
My array $teams is fine and when Im using the {debug} , all the information is correct, but when I view the page, the first option in the loop is blank. I have attached an image so you can see.

Have I done something trivial here???
Attached Images
File Type: gif list.GIF (4.6 KB, 3 views)
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline  
Old 05-03-2006, 08:57 AM   #2
Moderator
 
 
Join Date: Mar 2006
Location: NJ/NYC Area
Posts: 2,182
Rep Power: 59
juven14 is a jewel in the rough
Default

why not use foreach?

HTML Code:
<option value="">Select a Team</option> 
{foreach from=$teams item=item}
<option value="{$item.TID}">{$item.name}</option> 
{/foreach}
__________________
TemplateCodes.com
juven14 is offline  
Old 05-03-2006, 09:08 AM   #3
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

Well I probably can but it is bugging me now as I have this piece of dotted about my site with no probs whatsoever.

I will try the foreach though.
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline  
Old 05-03-2006, 09:12 AM   #4
Moderator
 
 
Join Date: Mar 2006
Posts: 4,227
Rep Power: 103
Lhotch is just really niceLhotch is just really nice
Default

see if adding start=1 helps.....

PHP Code:
<form action="addplayer.php" name="addplayer" method="get" >
<
select id="selectteam" name="selectteam" start=1>
<
option value="">Select a Team</option>
{
section name=select loop=$teams}
<
option value="{$teams[select].TID}">{$teams[select].name}</option>
{/
section}
</
select
Oh, and by the way I moved this to mod forum.
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Lhotch is offline  
Old 05-03-2006, 09:14 AM   #5
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

Works thanks Juven.

Just to let you know that the fantasy sports mod should be finished by the end of this week. Im just doing the admin panel as we speak.

This version will be perfect for the FIFA World Cup.
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline  
Old 05-03-2006, 09:18 AM   #6
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

Thanks Larry, but for some reason my array starts at 0 yet doesnt display the 0 when I debug.

PHP Code:
 => Array (2)
  
TID => 32
  name 
=> Angola
=> Array (2)
  
TID => 1
  name 
=> Argentina etc.... 
I tried start=1 but that starts with Argentina, where as 0 leaves a blank once again
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline  
Old 05-03-2006, 09:27 AM   #7
Moderator
 
 
Join Date: Mar 2006
Location: NJ/NYC Area
Posts: 2,182
Rep Power: 59
juven14 is a jewel in the rough
Default

Can you post the entire section where you create the array before passing it to the template?
__________________
TemplateCodes.com
juven14 is offline  
Old 05-03-2006, 09:32 AM   #8
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

PHP Code:
$sSQL="SELECT TID, name FROM fpro_teams ORDER BY name ASC";
$result=$db->query($sSQL);
while (
$rs=$result->fetch()){
          
$tmp = array(
                
'TID'         => $rs['TID'],
                
'name'        => $rs['name']
            );
     
$teams[$i++] = $tmp
            } 
$class_tpl->assign('teams'$teams); 
Its the standard format I have used throughout my site. There is no need to worry about it now Im using the foreach but I it is just a bit frustrating when you cant find whats up with your code.

__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline  
Old 05-03-2006, 09:41 AM   #9
Moderator
 
 
Join Date: Mar 2006
Location: NJ/NYC Area
Posts: 2,182
Rep Power: 59
juven14 is a jewel in the rough
Default

I hear you, I am the same way. I just wanted to be sure that wasn't the problem. Section should start at 0 by default, so it is strange behavior.

Just curious, but try adding a comma after
PHP Code:
'name' => $rs['name'], 
Not saying that will do it, but that is the only thing I can see different.
__________________
TemplateCodes.com
juven14 is offline  
Old 05-03-2006, 11:40 AM   #10
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

Caused an error with the comma in Juven.

THis thing is really coming together now, quite proud of myself. I will post you a screen shot tomorrow!
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline  
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Smarty Templates and You. Posted BY Lhotch Eric Barnes HTML, CSS, and Design Help 13 10-02-2007 08:06 AM
Displaying a Multidimensional Array Results in Smarty Maffo v3.1 Questions & Support 7 12-20-2006 08:41 AM
List of Smarty Variables and Arguments? bgordon v3.1 Modules & Modifications 5 09-12-2006 03:06 PM
Smarty TPL and Rotations xanthari HTML, CSS, and Design Help 1 07-20-2006 04:02 PM
Smarty Error ropingtony v3.1 Questions & Support 3 07-19-2006 05:03 PM


All times are GMT -4. The time now is 07:31 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0