사이즈를 체크하고 상품명을 넣고 검색하면 해당 사이즈의 상품만 나오게 하는방법

사이즈를 체크하고 상품명을 넣고 검색하면 해당 사이즈의 상품만 나오게 하는방법

QA

사이즈를 체크하고 상품명을 넣고 검색하면 해당 사이즈의 상품만 나오게 하는방법

본문

사이즈를 체크하고 상품명을 넣고 검색하면 해당 상품만 나오게 하려고합니다.

 

2049206488_1539800625.0254.png

 

 

 

2049206488_1539800813.4706.png

상품 등록 부분에 저렇게 채크박스 만들어주고

 

DB처리하는걸 만들어서

이런식으로 DB에 숫자가 저장되게 만들었습니다.

 

2049206488_1539800907.8289.png

 

검색하는 부분은 이렇게 짰는대

예를들어 사이즈 M을 채크 하고 상품명을 넣고 검색하면 M에 해당되는 DB 컬럼 sstype2에는 숫자가 0이라 검색이 되면 안되는대 검색이 되내요 1이면 검색하고 0이면 검색이 안되게 하려고 합니다.

 

검색부분 전체소스

https://nofile.io/f/8tO5ae7H4Ps/%EC%95%95%EC%B6%95.zip

 

 

검색화면 부분

                <input type="checkbox" name="it_sttype1" id="it_sttype1" value="1" <?php echo $it_sttype1_check?'checked="checked"':'';?>> <label for="it_sttype1">S</label>
                <input type="checkbox" name="it_sttype2" id="it_sttype2" value="1" <?php echo $it_sttype2_check?'checked="checked"':'';?>> <label for="it_sttype2">M</label>
                <input type="checkbox" name="it_sttype3" id="it_sttype3" value="1" <?php echo $it_sttype3_check?'checked="checked"':'';?>> <label for="it_sttype3">XL</label>
                <input type="checkbox" name="it_sttype4" id="it_sttype4" value="1" <?php echo $it_sttype4_check?'checked="checked"':'';?>> <label for="it_sttype4">XXL</label>

 

검색 부분

        if($_REQUEST['it_sttype1']!=""){

   $sizefind.="or it_sttype1='1'";
}

if($_REQUEST['it_sttype2']!=""){

   $sizefind.="or it_sttype2='1'";
}

if($_REQUEST['it_sttype3']!=""){

   $sizefind.="or it_sttype3='1'";
}

if($_REQUEST['it_sttype4']!=""){

   $sizefind.="or it_sttype4='1'";

이 질문에 댓글 쓰기 :

답변 1


$tmpSize = '';
if($_REQUEST['it_sttype1']!=""){
   $tmpSize[] ="it_sttype1='1'";
}
if($_REQUEST['it_sttype2']!=""){
   $tmpSize[] ="it_sttype2='1'";
}
if($_REQUEST['it_sttype3']!=""){
   $tmpSize[] ="it_sttype3='1'";
}
if($_REQUEST['it_sttype4']!=""){
   $tmpSize[] ="it_sttype4='1'";
}
 
$tmpSize = implode(" or ", $tmpSize);
$sizefind .= "(".$tmpSize.")";
답변을 작성하시기 전에 로그인 해주세요.
전체 123,588 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT