query("SHOW COLUMNS FROM {$DB}.{$tablename}"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $columns[] = $row['Field']; } // 각 컬럼에 대해 LIKE 검색 조건 추가 $searchConditions = []; foreach ($columns as $index => $col) { $paramName = ":search{$index}"; $searchConditions[] = "$col LIKE $paramName"; $bindParams[$paramName] = "%{$search}%"; } if (!empty($searchConditions)) { $conditions[] = "(" . implode(" OR ", $searchConditions) . ")"; } } // Build final SQL query $sqlWhere = implode(" AND ", $conditions); $sqlOrder = "ORDER BY num DESC"; $sql = "SELECT * FROM {$DB}.{$tablename} WHERE {$sqlWhere} {$sqlOrder}"; // Execute query $stmh = $pdo->prepare($sql); // Bind all parameters using bindValue foreach ($bindParams as $key => $value) { $stmh->bindValue($key, $value, PDO::PARAM_STR); } $stmh->execute(); // print($sql); // Output results as HTML table rows while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) { $num = $row['num']; $item_sep = $row['item_sep']; // 대분류 $model_UA = $row['model_UA']; // 인정/비인정 $item_bending = $row['item_bending']; // 중분류 $itemName = $row['itemName']; $item_spec = $row['item_spec']; $material = $row['material']; $widthsum = $row['widthsum']; $memo = $row['memo']; $imgdata = $row['imgdata']; $upload_dir = '../bending/img/'; // Calculate bending count $sumList = array_filter([ $row['sum1'], $row['sum2'], $row['sum3'], $row['sum4'], $row['sum5'], $row['sum6'] ], function($v) { return $v !== false; }); $bendingCount = count($sumList) > 0 ? (count($sumList) - 1) : 0; // Calculate other counts like in list.php $colorList = array_filter([ $row['color1'], $row['color2'], $row['color3'], $row['color4'], $row['color5'], $row['color6'] ], function($v) { return $v !== false; }); $AList = array_filter([ $row['A1'], $row['A2'], $row['A3'], $row['A4'], $row['A5'], $row['A6'] ], function($v) { return $v !== false; }); // Output row echo "