0 ){ $page = $_GET['page']; }else{ $page = 1; } $where_sql = ""; if($_GET['key']){ switch($_GET['key']){ case "free": // フリーキーワード $free = htmlspecialchars($func->trim_fullspace($_POST['free'])); $category = htmlspecialchars($_POST['category']); $result = $db->query("select distinct change_word from m_keyword where search_word = '%" . $free . "%'"); // if($_GET['free']){ $free = $_GET['free']; } // if($_GET['category']){ $category = $_GET['category']; } // if ($free == ""){ $free = htmlspecialchars($func->trim_fullspace($_POST['hid_free'])); } // if ($category == ""){ $category = htmlspecialchars($_POST['hid_category']); } //2012/04/20 del start // if($free){ // $where_sql = "( ts.hinban collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($free)) ."%' or" // . " ts.hinmei collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($free)) ."%' or" // . " ts.set_naiyou collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($free)) ."%' or" // . " ts.tokuchou collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($free)) ."%' ) and"; // } //2012/04/20 del end //2012/04/20 add start //フリーワード検索文言が存在した場合 if($free){ // キーワード紐付け処理 $result_change = $db->query("select distinct change_word from m_keyword where search_word collate utf8_unicode_ci = '" . $free . "'"); //検索結果のカウント取得 $result_change_cnt = mysql_num_rows ( $result_change ); //紐付けキーワードがある場合 if ($result_change_cnt > 0) { $where_sql = "( "; //紐付けキーワードを検索条件として指定 while($row_change = mysql_fetch_assoc( $result_change )){ $where_sql .= " ts.hinban collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($row_change[change_word])) ."%' or" . " ts.hinmei collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($row_change[change_word])) ."%' or" . " ts.set_naiyou collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($row_change[change_word])) ."%' or" . " ts.tokuchou collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($row_change[change_word])) ."%' or"; } // 最後の'or'を削除 $where_sql = mb_substr($where_sql, 0, mb_strlen($where_sql) - 2, "UTF-8"); $where_sql .= ") and"; } else { $where_sql = "( ts.hinban collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($free)) ."%' or" . " ts.hinmei collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($free)) ."%' or" . " ts.set_naiyou collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($free)) ."%' or" . " ts.tokuchou collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($free)) ."%' ) and"; } } //2012/04/20 add end if($category){ $where_sql .= " tscb.category_cd like '". mysql_real_escape_string($category) ."%' and"; $join_sql = "left outer join t_seihin_category_body tscb " . " on (ts.jan_cd = tscb.jan_cd and ts.hinban = tscb.hinban) "; } if($where_sql !== ""){ // 最後の'and'を削除 $where_sql = mb_substr($where_sql, 0, mb_strlen($where_sql) - 3, "UTF-8"); $where_sql = $join_sql . " where " . $where_sql; } break; case "item": // 品番・品名検索 //品番 取得 $hinban = htmlspecialchars($func->trim_fullspace($_POST['hinban'])); if($hinban == ""){ $hinban = htmlspecialchars($func->trim_fullspace($_POST['hid_hinban'])); } // 品名 取得 $hinmei = htmlspecialchars($func->trim_fullspace($_POST['hinmei'])); if($hinmei == ""){ $hinmei = htmlspecialchars($func->trim_fullspace($_POST['hid_hinmei'])); } // JANコード 取得 $jan = htmlspecialchars($func->trim_fullspace($_POST['jan'])); if($jan == ""){ $jan = htmlspecialchars($func->trim_fullspace($_POST['hid_jan'])); } $hinmei_tmp = $hinmei; if($hinban){ $where_sql .= " ts.hinban collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($hinban)) ."%' and"; } if($hinmei){ //半角カタカナ濁音にて登録されている場合の為、濁音を削除 $where_sql .= " ts.hinmei collate utf8_unicode_ci like '%". mysql_real_escape_string($func->conv_hankaku($hinmei_tmp)) ."%' and"; $hinmei_tmp = ''; } if($jan){ $where_sql .= " ts.jan_cd collate utf8_unicode_ci like '%" . mysql_real_escape_string($jan) . "%' and"; } if($where_sql !== ""){ // 最後の'and'を削除 $where_sql = mb_substr($where_sql, 0, mb_strlen($where_sql) - 3, "UTF-8"); $where_sql = " where " . $where_sql; } break; case "style": // 形状検索 $where_sql_tmp = ""; // 普通形状 $result = $db->query("select distinct keijou_cd from m_keijou_size "); while($row = mysql_fetch_assoc( $result )){ $chkSize = $_POST["hidden_size_{$row[keijou_cd]}"]; if($chkSize){ $chkSizeString = ""; for( $i = 0; $i < count($chkSize); $i++){ if($chkSize[$i] !== ""){ $chkSizeString .= $chkSize[$i] . ","; } } if($chkSizeString !== ""){ // 最後の','を削除 $chkSizeString = substr($chkSizeString, 0, strlen($chkSizeString) - 1); $where_sql_tmp .= "(tskb.keijou_cd = {$row[keijou_cd]} and tskb.keijou_size_cd in({$chkSizeString}) ) or"; } } } $join_sql = "left outer join t_seihin_keijou_body tskb " . " on (ts.jan_cd = tskb.jan_cd and ts.hinban = tskb.hinban) "; // 特殊形状 $chkTokusyu = $_POST["tokusyu"]; if($chkTokusyu){ $chkTokusyuString = ""; for( $i = 0; $i < count($chkTokusyu); $i++){ $chkTokusyuString .= $chkTokusyu[$i] . ","; } if($chkTokusyuString !== ""){ // 最後の','を削除 $chkTokusyuString = substr($chkTokusyuString, 0, strlen($chkTokusyuString) - 1); $where_sql_tmp .= "(tskb.keijou_cd in({$chkTokusyuString}) ) or"; } } $where_sql .= $where_sql_tmp; if($where_sql !== ""){ // 最後の'or'を削除 $where_sql = mb_substr($where_sql, 0, mb_strlen($where_sql) - 2, "UTF-8"); $where_sql = $join_sql . " where " . $where_sql; } break; default: break; } } // GET変数に何もないとき、初期画面のため検索結果を出さないようにする if(!$_GET){ if($where_sql !== ""){ $where_sql .= " and"; }else{ $where_sql .= " where "; } $where_sql .= " ts.hinban ='' and ts.jan_cd =''"; } // 一行形式か表形式か取得 $disp_block = $_POST['disp_block']; ?> 製品検索・検索システム | ドライバー 先端工具・作業工具・ピンセット&クラフトツールの三条市ANEX(株)兼古製作所

兼古製作所

形状で検索

query("select distinct keijou_cd from m_keijou_size "); while($row = mysql_fetch_assoc( $result )){ $dmy = ''; $result_size = $db->query("select keijou_size_cd, keijou_size_name from m_keijou_size where keijou_cd = {$row[keijou_cd]} and hyouji_kbn = 1 order by keijou_size_cd"); if(mysql_num_rows ( $result_size ) > 0){ $cnt = 0; $dmy = <<            
    EOT; while($row_size = mysql_fetch_assoc( $result_size )){ //POSTにチェックボックスで渡せれた配列がある、かつその配列に該当の形状サイズコードがある場合チェック $checked = ($_POST["hidden_size_$row[keijou_cd]"] && in_array($row_size[keijou_size_cd], $_POST["hidden_size_$row[keijou_cd]"])) ? ' checked="checked"' : ''; $dmy .= << EOT; $cnt++; } $dmy .= <<       EOT; $dmy = "\n"; $array_size_html[$row[keijou_cd]] = $dmy; } $result_size = $db->query("select keijou_size_cd, keijou_size_name from m_keijou_size where keijou_cd = {$row[keijou_cd]} and hyouji_kbn = 1 order by keijou_size_cd"); if(mysql_num_rows ( $result_size ) > 0){ while($row_size = mysql_fetch_assoc( $result_size )){ //POSTにチェックボックスで渡せれた配列がある、かつその配列に該当の形状サイズコードがある場合、hiddenに値を保持 if($_POST["hidden_size_$row[keijou_cd]"] && in_array($row_size[keijou_size_cd], $_POST["hidden_size_$row[keijou_cd]"])){ $dmy = ""; }else{ $dmy = ""; } $array_size_html[$row[keijou_cd]] .= $dmy; } } } ?> query("select tokusyu_kbn, keijou_cd, keijou_name from m_keijou order by sort_no"); $result_cnt = mysql_num_rows ( $result ); if ($result_cnt > 0) { print "
      \n"; for( $i = 0; $i < $result_cnt; $i++){ $row = mysql_fetch_assoc( $result ); print "
    • \n"; if ($row['tokusyu_kbn'] <> 1) { // 通常形状の場合 $checked = ($_POST["keijou_{$row[keijou_cd]}"]) ? ' checked="checked"' : ''; print ""; } else { // 特殊形状の場合 $checked = ( $chkTokusyu && in_array( $row[keijou_cd], $chkTokusyu)) ? ' checked="checked"' : ''; print ""; } if (strlen($array_size_html[$row[keijou_cd]]) > 0) { echo $array_size_html[$row[keijou_cd]]; } print "
    • \n"; } print "
    \n"; } print ""; print ""; print ""; print ""; print ""; echo << EOT; ?>

検索結果

query("select distinct ts.hinban, ts.hinmei, ts.jan_cd from t_seihin as ts {$where_sql} order by ts.sort_no "); $resultAll_cnt = mysql_num_rows ( $resultAll ); $minTmp = CONST_PARAM::MAXITEM * $page - CONST_PARAM::MAXITEM ; $result = $db->query("select distinct ts.hinban, ts.hinmei, ts.jan_cd, tssb.size from t_seihin AS ts left outer join (select distinct hinban, jan_cd , size from t_seihin_size_body where renban = 0 ) tssb on (ts.jan_cd = tssb.jan_cd and ts.hinban = tssb.hinban) {$where_sql} order by ts.sort_no, ts.hinban limit {$minTmp}," . CONST_PARAM::MAXITEM); $dispMin = $minTmp + 1; $all_pages = ceil($resultAll_cnt / CONST_PARAM::MAXITEM); // 全ページ数を計算 $page_control = ''; if ($resultAll_cnt > 0) { $page_control = "
\n"; $page_control .= "

{$resultAll_cnt} 商品中 {$dispMin}-"; if($resultAll_cnt < CONST_PARAM::MAXITEM * $page){ $page_control .= "{$resultAll_cnt} 商品

"; }else{ $page_control .= CONST_PARAM::MAXITEM * $page." 商品

"; } $page_control .= "

"; $cls = ($page > 1) ? 'befaft' : 'befaft_disable'; $page_control .= "<<"; $page_control .= "前へ"; //分割ページの制御 1~5ページ if ($page == '1' || $page == '2'|| $page == '3'){ if ( $all_pages < 5 ) { $line_last = $all_pages; } else { $line_last = 5; } for ($i = 1; $i <= $line_last; $i++) { $cls = ($page == $i) ? 'current_page' : 'befaft'; $page_control .= "{$i}"; } if ($all_pages > 5) { $page_control .= "..."; } //分割ページの制御 ~lastページ } elseif ($page == $all_pages || $page == ($all_pages - 1) || $page == ($all_pages - 2)) { if ( $all_pages <= 5 ) { $line_first = 1; } else { $line_first = $all_pages - 4; } if ($page > 5) { $page_control .= "..."; } for ($i = $line_first; $i <= $all_pages; $i++) { $cls = ($page == $i) ? 'current_page' : 'befaft'; $page_control .= "{$i}"; } //分割ページの制御 ○~○ページ } else { if ($page > 3) { $page_control .= "..."; } for ($i = $page - 2; $i <= $page + 2; $i++) { $cls = ($page == $i) ? 'current_page' : 'befaft'; $page_control .= "{$i}"; } if ($page < ($all_pages - 2)) { $page_control .= "..."; } } $cls = ($page < $all_pages) ? 'befaft' : 'befaft_disable'; $page_control .= "次へ"; $page_control .= ">>"; $page_control .= "

\n"; $page_control .= "
\n"; } else { // 0商品の表示 $page_control = "
\n"; $page_control .= "

{$resultAll_cnt} 商品中 {$resultAll_cnt}-"; $page_control .= "{$resultAll_cnt} 商品

"; $page_control .= "
"; $page_control .= "
\n"; } // 商品数・ページ遷移の為のHTMLを出力 echo $page_control; ?>
2) ? 1 : $class_cnt; // 一行ごと表示用のHTM print ""; print ""; print ""; print ""; print "\n"; $class_cnt++; } ?>