<?php $choice->clear(); $cate_id = $pro2->f('id'); $pro->get_attachments($cate_id); while ($pro->next_record()) { if (isset($list_attach[$cate_id])) { if (in_array($pro->f('product_id'), $list_attach[$cate_id])) { $choice->add_option($pro->f('product_name'), $pro->f('product_id'), true); } else { $choice->add_option($pro->f('product_name'), $pro->f('product_id')); } } else { $choice->add_option($pro->f('product_name'), $pro->f('product_id')); } } $choice->print_choice_list('frmProduct', 'attach_' . $pro2->f('id')); ?> <input type="hidden" name="attachment_categories[]" value="<?php echo $pro2->f('id'); ?> "> </td> </tr> <?php } } $choice->select_all(); ?> <tr>