[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] sql queries inside perl tag
Hello all,
I'm having problems with some code inside of a perl tag. Unfortunatley, I
have a products table with a column (sun) that has a list of comma
seperated numbers (ex 5,6,7,8)
and a sun table that has the correspondings values
1 NO Shade
2 Some Shade
3 Half shade
4 Some sun
etc etc
I realize that this is a poor db design, but it was written years ago by a
predecessor ;-)
Any ways this is what I'm trying to do...
I need to look up the value in products->sun (5,6,7,8)
split the results into an array, then do a lookup for each number in the
array and display the results
Here's my code:
[perl]
my $suninfo = [sql]SELECT sun FROM products WHERE code = '[item-code]'[/sql];
my $sunarray = split(/,/, $suninfo);
my $i = 0;
my $numelements = scalar(@sunarray);
while ( $i < $numelements)
{
$textvalue = [sql]SELECT val FROM sun WHERE code = $sunarray[$i][/sql];
print($textvalue);
$i++;
}
[/perl]
Here's the error log message:
207.166.192.127 v8iccWcx:207.166.192.127 - [01/August/2001:17:50:01 -0400]
bluestone /cgi-bin/bluestone.cgi/ABDIP.html Safe: syntax error at (eval
377) line 2, near "]SELECT sun "
> Missing right curly or square bracket at (eval 377) line 3, within pattern
>
>
> my $suninfo = [sql]SELECT sun FROM
products WHERE code = 'ABDIP'[/sql];
> my $sunarray = split(/,/, $suninfo);
> my $i = 0;
> my $numelements = scalar(@sunarray);
> while ( $i < $numelements)
> {
> $textvalue = [sql]SELECT val FROM
sun WHERE code = $sunarray[$i][/sql];
> print($textvalue);
> $i++;
> }
What am I missing???!!!?!?!?!?!?!
Brian Kosick
Web Programmer
New Age Consulting Service, Inc.
216-619-2000
briank@nacs.net
_______________________________________________
interchange-users mailing list
interchange-users@lists.akopia.com
http://lists.akopia.com/mailman/listinfo/interchange-users