리스트에서 날짜검색 문의
본문
안녕하세요
게시판 리스트에서
아래의 소스로 날짜 검색을 이용중인데요
선택된 해당 날짜만 검색이 됩니다.
2022-01-01 ~ 2022-01-02
이런식으로 선택한 기간을 검색하고 싶습니다.
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
<script>
$.datepicker.setDefaults({
dateFormat: 'yy-mm',
prevText: '이전 달',
nextText: '다음 달',
monthNames: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
monthNamesShort: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
dayNames: ['일', '월', '화', '수', '목', '금', '토'],
dayNamesShort: ['일', '월', '화', '수', '목', '금', '토'],
dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'],
showMonthAfterYear: true,
yearSuffix: '년'
});
$(function() {
$("#stx2, #e_Date").datepicker({
dateFormat: 'yy-mm-dd'
});
});
</script>
<form name="fsearch" method="get">
<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">
<input type="hidden" name="sfl" value="wr_datetime"<?php echo get_selected($sfl, 'wr_datetime'); ?>>
<input type="text" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx2" class="sch_input" size="25" maxlength="20" placeholder="날짜검색" autocomplete="off">
<button type="submit" value="검색" class="sch_btn"><i class="fa fa-search" aria-hidden="true"></i><span class="sound_only">검색</span></button>
</form>
해당 날짜 검색은 아주 잘되는데
기간 검색은 어디서 부터 손을 대야할지 모르겟습니다.
고수님들 도움 부탁드립니다. ㅠ
!-->
답변 3
* /lib/common.lib.php - function get_sql_search() {
1) global $g5;
->
global $g5, $stx2;
2)
switch ($field[$k]) {
case "mb_id" :
case "wr_name" :
$str .= " $field[$k] = '$s[$i]' ";
break;
case "wr_datetime" :
$str .= " $field[$k] between '$s[$i]' and '$stx2' ";
break;
lib/common.lib.php에
// 검색 구문을 얻는다.
function get_sql_search()함수를 고치면 됩니다.
switch ($field[$k]) {
case 'wr_datetime': 기간 조건문; // 이렇게 추가하시면 됩니다.
case "mb_id" :
case "wr_name" :
답변을 작성하시기 전에 로그인 해주세요.