게시판 분류(카테고리)와 검색 연동
본문
위 사진처럼 제목, 내용으로 검색하지 않고 카테고리로 검색할 수 있나요?
혹시 연동하는 방법 알려주신다면 감사하겠습니다..
아래는 폼 코드입니다.
<fieldset class="bo_sch">
<form name="fsearch" method="get" class="selectbox">
<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
<input type="hidden" name="sca" value="<?php echo $sca ?>">
<input type="hidden" name="sop" value="and">
<?php if ($is_category) { ?>
<form name="fcategory" method="get">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
<select name="sca">
<option value=''>전체</option>
<?php echo get_category_option($bo_table, $sca); // SELECT OPTION 태그로 넘겨받음 ?>
</select>
<input type="submit" value="확인" class="sel_btn">
</form>
<?php } ?>
<div class="sch_bar">
<input type="text" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx"
class="sch_input" size="25" maxlength="20" placeholder=" 무엇을 도와드릴까요?">
<button type="submit" value="검색" class="sch_btn"><i class="fa-solid fa-magnifying-glass"></i>
<span class="xbtn"><i class="fa-solid fa-xmark"></i></span>
</button>
</div>
</form>
</fieldset>
답변 2
sca 가 중복이고
submit 버튼도 두개,
form 안에 form 이 있습니다.
이부분들 아래와 같이 바로잡고 확인해보세요
<fieldset class="bo_sch">
<form name="fsearch" method="get" class="selectbox">
<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
<!-- <input type="hidden" name="sca" value="<?php echo $sca ?>"> -->
<input type="hidden" name="sop" value="and">
<select name="sfl" id="sfl">
<option value="wr_subject">제목</option>
<option value="wr_content">내용</option>
<option value="wr_subject||wr_content">제목+내용</option>
<option value="wr_name,1">글쓴이</option><option value="wr_name,0">글쓴이(코)</option>
</select>
<?php if ($is_category) { ?>
<!--
<form name="fcategory" method="get">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
-->
<select name="sca">
<option value=''>전체</option>
<?php echo get_category_option($bo_table, $sca); // SELECT OPTION 태그로 넘겨받음 ?>
</select>
<!--
<input type="submit" value="확인" class="sel_btn">
</form>
-->
<?php } ?>
<div class="sch_bar">
<input type="text" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx"
class="sch_input" size="25" maxlength="20" placeholder=" 무엇을 도와드릴까요?">
<button type="submit" value="검색" class="sch_btn"><i class="fa-solid fa-magnifying-glass"></i>
<span class="xbtn"><i class="fa-solid fa-xmark"></i></span>
</button>
</div>
</form>
</fieldset>
<form name="fcategory" id="fcategory" method="get">
<select name="sca" id="sca">
<script>
$("#sca").change( function() {
$("#fcategory").submit();
});
</script>
form이랑 select에 id값 추가하고 script 삽입 이런느낌이요?
!-->
답변을 작성하시기 전에 로그인 해주세요.