[ic] looping vs. query

Dean Hall php@apt7.com
Sat, 28 Apr 2001 12:16:46 -0500

I'm working on a project that I'm trying to get working with SQL, but I'm
settling for gdbm right now just to get it working. Due to the awful, awful
documentation for Interchange, I need some help.

I have no idea what the arguments to [loop search] are. For example [loop
search='fi=table_name/se=column_value/sf=column_name'] -- I think the
associations I've put are correct, but I'm not sure.

I have the products table with the following attributes:

product_id - numeric primary key
price - numeric
taxable - numeric
category_id - numeric (foreign key)

I'm trying to get every row in the DB with category_id of 2. Here's what I

[loop prefix='prod' interpolate=1 search='fi=products/se=[scratch

[scratch category_id] resolves to 2 in this case; the problem is that I'm
getting a bunch of garbage when I reference [prod-code], [prod-field name],
or any other [prod-field xxx].

I've even tried doing:

[query prefix='prod' interpolate=1 sql="select * from products where
category_id='[scratch category_id]'"]

This works, but I need to use the [loop-alternate n] construct to start a
new table row when I've already gone through 3 (or whatever) products.
[query] seems to have no similar construct, and I can't reset a scratch
variable after it's been set (even with
[calc]$Scratch->counter++;return;[/calc]) -- so it seems I must use
[loop-alternate 3].

Any thoughts?