[ic] loop question

Peter peter at pajamian.dhs.org
Wed Oct 25 17:59:36 EDT 2006

On 10/25/2006 07:22 AM, DB wrote:
> I'm running 5.4.1 and have the below hunk of code which displays
> information about the items from a given order. The last column shows
> the quantity of the item in our inventory and all of this works fine.
> Now I've added a field named "notes" to the inventory table and I'd like
> to display that field right next to the quantity. I tried simply changing
> [itemlist-data inventory quantity]
> to
> [itemlist-data inventory quantity] [itemlist-data inventory notes]
> but the notes are not showing up. Can someone tell me why this is?
> Here's the code hunk:
> 	[loop search="
>                         fi=orderline
> 			ra=no
> 			ml=1000
> 			st=db
>                         se=[my-data transactions order_number]
>                         sf=order_number
> 		"]
> <tr><td align="center" colspan=4>
> <table cellspacing="5" align="left" width="95%"><tr>
> <td width="10%">[loop-data orderline code]</td>
> <td width="15%">[loop-data orderline sku]</td>
> <td width="25%">[loop-data orderline description]</td>
> <td width="10%">[loop-data orderline quantity]</td>
> <td width="15%">[loop-data orderline price]</td>
> <td width="15%">[loop-data orderline subtotal]</td>

This is horribly inefficient.  You're telling it to query the DB once
for the loop, plus 7 separate time for each result.  This could easily
result in hundreds of DB hits in one page.  Try adding:
...to the searchspec and then fetch the values with [loop-code]
[loop-param sku] [loop-param description] etc.  You will reduce hundreds
of DB hits down to just one.

> <td width="10%">
> [loop prefix=itemlist search="se=[loop-data orderline
> sku]/fi=inventory/sf=sku/"]
> [itemlist-data inventory quantity]

Same thing here.  Do:
[loop prefix=itemlist search="
    se=[loop-param sku]
[itemlist-param quantity]
[itemlist-param notes]

> [/loop]

For more info see:


More information about the interchange-users mailing list