如何在foreach循环中更新多个字段记录?

时间:2018-07-29 06:38:17

标签: php mysql multiple-columns

我正在尝试使用foreach循环更新多个记录,但是它将替换为先前的记录:

Table structure

TableID ----  ProductID --- Color ---- ImageSample

foreach($Extras['ColorText'] as $key=>$val)
{
    $query = "update productcolor set 
    Color = '".$Extras['ColorText'][$i]."' Where
    ProductID = '".$RecordID."' ";
    echo $query;
    $App1->query($query);

    $i++;
}

我的HTML代码:

<td align="left" valign="top">Product <br />
    <input type='text' name='Color[]' class='auto TextField' value="<?php echo $App->f("Color"); ?>"></td>
</td>

显示查询:

update productcolor set Color = 'sdasdas', ImageSample = '' Where ProductID = '93' update productcolor set Color = 'sdasdas', ImageSample = '' Where ProductID = '93' update productcolor set Color = 'Yellow', ImageSample = 'listing.png' Where ProductID = '93'

0 个答案:

没有答案