<tr data-subpart_id="<?= $subRow['subpart_id'] ?>">  
  <td class="text-center">
    <div class="d-flex justify-content-center">
      <span class="subpart-serial mx-1"><?= $subNum /* 계산된 일련번호 */ ?></span>
      <button type="button" style="padding:2;" class="btn btn-primary btn-sm search-bending-btn" onclick="openBendingSearchModal(this)">
        <i class="bi bi-search"></i>
      </button>
    </div>
  </td>  
  <td class="text-center">
    <input type="text" name="subpart_name[]" class="form-control" value="<?= htmlspecialchars($subRow['subpart_name'], ENT_QUOTES, 'UTF-8') ?>">
  </td>  
  <td class="text-center">
    <input type="text" name="sub_spec[]" class="form-control" value="<?= htmlspecialchars($subRow['spec'], ENT_QUOTES, 'UTF-8') ?>">
  </td>
  <td class="text-center">
    <input type="text" name="material[]" class="form-control" value="<?= htmlspecialchars($subRow['material'], ENT_QUOTES, 'UTF-8') ?>">
  </td>
  <td class="text-center">
    <input type="text" name="horizontal_width[]" class="form-control" value="<?= htmlspecialchars($subRow['horizontal_width'], ENT_QUOTES, 'UTF-8') ?>">
  </td>
  <td class="text-center">
    <input type="text" name="vertical_width[]" class="form-control" value="<?= htmlspecialchars($subRow['vertical_width'], ENT_QUOTES, 'UTF-8') ?>">
  </td>
  <td class="text-center">
    <?php 
      $img = htmlspecialchars($subRow['image_url'], ENT_QUOTES, 'UTF-8');
      if ($img) {
          $img_path = "/bending/img/" . $img;
          echo '<img src="' . $img_path . '" alt="이미지" style="max-width:100px;">';
      } else {
          echo '(선택)';
      }
    ?>
  </td>
  <td class="text-center">
    <button type="button" class="btn btn-outline-dark btn-sm add-subpart-row">+</button>
    <button type="button" class="btn btn-outline-danger btn-sm remove-subpart-row">-</button>
    <input type="hidden" name="subpart_id[]" value="<?= $subRow['subpart_id'] ?>">
    <!-- 부모 부품 ID를 숨김필드로 포함 -->
    <input type="hidden" name="parent_part_id[]" value="<?= $partRow['part_id'] ?>">
    <input type="hidden" name="image_url[]" value="<?= $subRow['image_url'] ?>">
  </td>
</tr>
