[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] sql - multiple rows in one click update - product "genres"
Hello,
here is a ssmall piece of code wich is one "solution for the problem i
wrote in my post of 05-19-2002 15:03 (Paris)
One trouble still living.
When I press, one or more times, the submit button results from [calc]
display (used below) switch with the mysql database"
When somebody knows what happend. I think it could be because of CGI
variables update moment. I'm not proof in internal Interchange.
Somebody got an Idea ???
MERCI
Alain
@_UI_STD_HEAD_@
[set mv_data_enable]1[/set]
<FORM ACTION="" METHOD=POST NAME="main">
<INPUT type=hidden NAME="item_id" VALUE="[cgi item_id]">
<input type="hidden" name="mv_todo" value="set">
[query list=1 prefix=outer sql="SELECT id,genre_id
FROM produits_genres
WHERE sku = '[cgi item_id]'"]
<input type="hidden" name="ids" value="[outer-param id]">
<select name="genres" size="5">
[loop prefix=inner
search="
st=sql
fi=genres
ra=yes
rf=genre_id,genre_nom
"]
<option value="[inner-param genre_id]"
[if explicit]
[condition]
$inner = '[inner-param genre_id]';
$outer = '[outer-param genre_id]';
return 1 if $outer =~ /$inner/i;
return 0;
[/condition]
selected
[/if]>[inner-param genre_id] - [inner-param genre_nom]</option>
[/loop]
</select>
[/query]
<input type="submit" name="mv_click" value="OK">
</form>
[set name="OK" interpolate=1]
[perl tables=produits_genres]
my @genres = split /\0/, $CGI->{genres};
my @ids = split /\0/, $CGI->{ids};
my $i = 0;
my $numelements = scalar (@genres);
while ( $i < $numelements)
{
$Tag->query({sql => "update produits_genres set
genre_id='@genres[$i]' where id='@ids[$i]'"});
$i++;
}
return;
[/perl]
[/set]