SocomNegotiator Posted June 2, 2010 Share Posted June 2, 2010 I have a products table that has a field called sizing. The sizing field contains an ID from another table called products_sizing. The main reason for the sizing field in the products table is to decipher which products have what kind of sizing method. For instance, some products (shirts) only are available in small and medium not large, but others have the option for all three. In the products table the sizing field shows which sizing method a product will have if any. {foreach from=$SizingMethods key=SizingID item=SizingRow name=SizingMethods} {if (what query should go here to only show the sizing methods a certain product has?)} <input name="sizingmethods" type="radio" id="sizingmethods{$SizingID}" value="{$SizingID}"/> <label for="sizingmethods{$SizingID}"> {$SizingRow.name} | {if $SizingRow.value ne 0} +{$SizingRow.value} {if $SizingRow.typename eq 'absolute'}{#CURRENCY#}{else}%{/if}{else} {#free#} {/if}</label><br /> {/if} {/foreach} Thanks in advance! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted June 2, 2010 Share Posted June 2, 2010 This isn't standard PHP. Are you using a template system like Smarty? Ken Quote Link to comment Share on other sites More sharing options...
SocomNegotiator Posted June 2, 2010 Author Share Posted June 2, 2010 This isn't standard PHP. Are you using a template system like Smarty? Ken Sorry, yes I am using a template. It is Smarty. I can though input regular code into the scripts. Quote Link to comment Share on other sites More sharing options...
SocomNegotiator Posted June 2, 2010 Author Share Posted June 2, 2010 Ok here is what I have come up with. The only problem with this code is that if I have more than one product the sizing methods for each product will be the last product to go through the loop. For instance, the first and second product will have the same sizing methods as the third even though the first and second product don't have the same sizing methods. Any ideas on how to fix this? Again this is a Smarty template, and I can use normal coding in the scripts. {foreach from=$ProdsCarts key=ProductID item=ProductRow name=ProductsLoop}//This goes through how many products there are. {if $ProductRow.sizing != ''} <tr class="head"> <td height="15" colspan="3" style="border:none;"><div align="justify">{#Sizing_Method#} ({$ProductRow.name})</div></td> </tr> <tr> <td colspan="2"> <div align="left"> {foreach from=$ProductSizing key=key item=isOn name=ProductsLoop} // This goes through the sizing methods. Right here I think is the problem. It does not associate with which product the sizing methods go with. <input name="sizingmethods" type="radio" id="sizingmethods{$SizingID}" value="{$SizingID}"/> <label for="sizingmethods{$SizingID}"> {$Sizing.$key.name} | {if $Sizing.$key.value ne 0} +{$Sizing.$key.value} {if $Sizing.$key.typename eq 'absolute'}{#CURRENCY#}{else}%{/if}{else} {#free#} {/if}</label><br /> {/foreach} </div></td> </tr> {else} {/if} {/foreach} Ideas???? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.