PHP 검색에 관해서....(사진첨부) 정보
PHP 검색에 관해서....(사진첨부)본문
먼저 그누보드쪽 질문이 아니라 죄송합니다. 그누보드 공부하면서 PHP라는걸 알게되었는데 이번에
PHP공부하다 막히는게 있어서 고수님들의 답변을 구하고자 글 올립니다.
소스는 회원DB를 관리자 페이지에서 보여주는건데요 소스보시면 날짜검색해서 볼수있는
sql구문이 있는데 검색은 다 잘되는데 이상하게 당일검색 하면 당일검색이 되질않습니다.
(예를 들면 오늘이 9월5일이라면 9월2일~9월2일 검색실행시 9월2일~9월5일까지 다 나옴)
sql 쿼리문에서 select 설정이 잘못되어서 그런건지...통 알수가 없습니다.혹시 아시는분 답변
부탁드리겠습니다.
그럼 즐건 하루 되세여~
<td valign="top"><BR><div align=center>[ 회원정보 ]</div><BR>
<TABLE border="1" cellpadding="0" cellspacing="0" bordercolor="#999999" width='650' bgColor=#CCCCCC align=center valign="top">
<form name=search action='<?=$PHP_SELF?>' method=POST>
<input type="hidden" name="find" value="1">
<TBODY>
<TR bgcolor="#FFFFFF">
<TD width="57">의뢰인</TD>
<TD colspan='3'>
<input type="text" name="name" value="<?=$name?>"></TD></TR>
<TR bgcolor="#FFFFFF">
<TD>의뢰일자</TD>
<TD colspan='3'>
<? $currentTime = time();
$timeinfo = getdate($currentTime);
if (!$fyear) { $fyear = $timeinfo["year"]; }
if (!$fmonth) { $fmonth = $timeinfo["mon"]; if(strlen($fmonth)==1) { $fmonth = "0" . $fmonth; } }
if (!$fday) { $fday = $timeinfo["mday"]; if(strlen($fday)==1) { $fday = "0" . $fday; } }
if (!$tyear) { $tyear = $timeinfo["year"]; }
if (!$tmonth) { $tmonth = $timeinfo["mon"]; if(strlen($tmonth)==1) { $tmonth = "0" . $tmonth; } }
if (!$tday) { $tday = $timeinfo["mday"]; if(strlen($tday)==1) { $tday = "0" . $tday; } }
if (!$thour) { $thour = date("H"); }
?>
<INPUT size=4 name=fyear value='<?=$fyear?>'>년
<INPUT size=2 name=fmonth value='<?=$fmonth?>'>월
<INPUT size=2 name=fday value='<?=$fday?>'>일 ~
<INPUT size=4 name=tyear value='<?=$tyear?>'>년
<INPUT size=2 name=tmonth value='<?=$tmonth?>'>월
<INPUT size=2 name=tday value='<?=$tday?>'>일
</td></tr>
<tr bgcolor="#FFFFCC">
<td height="17">
<div align="center">AD1</div></td>
<td colspan='3' valign=middle>
<input type="radio" name="mailtype" value="" <? if ($mailtype=="") { ?>checked<? } ?>>전체<input type="radio" name="mailtype" value="1" <? if ($mailtype=="1") { ?>checked<? } ?>>메일1<input type="radio" name="mailtype" value="2" <? if ($mailtype=="2") { ?>checked<? } ?>>메일2<input type="radio" name="mailtype" value="3" <? if ($mailtype=="3") { ?>checked<? } ?>>메일3<input type="radio" name="mailtype" value="4" <? if ($mailtype=="4") { ?>checked<? } ?>>메일4<input type="radio" name="mailtype" value="5" <? if ($mailtype=="5") { ?>checked<? } ?>>
메일5</TD>
</TR>
<tr bgcolor="#FFCCCC">
<td>
<div align="center">AD2</div></td>
<td colspan='3' valign=middle>
<input type="radio" name="mailtype" value="6" <? if ($mailtype=="6") { ?>checked<? } ?>>메일6
<input type="radio" name="mailtype" value="7" <? if ($mailtype=="7") { ?>checked<? } ?>>메일7
<input type="radio" name="mailtype" value="8" <? if ($mailtype=="8") { ?>checked<? } ?>>메일8
<input type="radio" name="mailtype" value="9" <? if ($mailtype=="9") { ?>checked<? } ?>>메일9
<input type="radio" name="mailtype" value="10" <? if ($mailtype=="10") { ?>checked<? } ?>>메일10
<input type="radio" name="mailtype" value="11" <? if ($mailtype=="11") { ?>checked<? } ?>>메일11
<input type="radio" name="mailtype" value="12" <? if ($mailtype=="12") { ?>checked<? } ?>>메일12
<input type="radio" name="mailtype" value="13" <? if ($mailtype=="13") { ?>checked<? } ?>>메일13
<input type="radio" name="mailtype" value="14" <? if ($mailtype=="14") { ?>checked<? } ?>>메일14 </TD>
</TR>
<tr bgcolor="#FFCCCC">
<td>
<div align="center">AD2</div></td>
<td colspan='3' valign=middle>
<input type="radio" name="mailtype" value="15" <? if ($mailtype=="15") { ?>checked<? } ?>>메일15
<input type="radio" name="mailtype" value="16" <? if ($mailtype=="16") { ?>checked<? } ?>>메일16
<input type="radio" name="mailtype" value="17" <? if ($mailtype=="17") { ?>checked<? } ?>>메일17
<input type="radio" name="mailtype" value="18" <? if ($mailtype=="18") { ?>checked<? } ?>>메일18
<input type="radio" name="mailtype" value="19" <? if ($mailtype=="19") { ?>checked<? } ?>>메일19
<input type="radio" name="mailtype" value="20" <? if ($mailtype=="20") { ?>checked<? } ?>>메일20 </TD>
</TR>
<tr bgcolor="#FFFFFF">
<td>처리단계</td>
<td colspan='3' valign=middle>
<input type="radio" name="state" value="" <? if ($state=="") { ?>checked<? } ?>>전체 <input type="radio" name="state" value="N" <? if ($state=="N") { ?>checked<? } ?>>의뢰대기 <input type="radio" name="state" value="Y" <? if ($state=="Y") { ?>checked<? } ?>>의뢰확인</TD></TR>
</TBODY></TABLE> <div align=right>
<INPUT type=button value=' 인쇄 ' style="cursor:hand" onClick="window.print();">
<INPUT type=button value='인쇄보기' style="cursor:hand" onClick="window.open('print.php','print','status=0, menubar=0, scrollbars=yes');">
<INPUT type=reset value='초기화' style="cursor:hand">
<INPUT type=submit value='검색실행' style="cursor:hand"></div>
</form>
<table width="650" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="650" align=center valign="top">
<p><?
$sql_tday = $tday + 1 ;
$query = "SELECT * from event where idx is not null and mailtype <21";
if($name) {
$where .= " and name = '".$name."'" ;
}
if($mailtype) {
$where .= " and mailtype = '".$mailtype."'" ;
}
if($state) {
$where .= " and state = '".$state."'" ;
}
if($find) {
$where .= " and regdate >= '".$fyear . $fmonth . $fday . "' and regdate < '" . $tyear . $tmonth . $sql_tday . "'" ;
}
$order = " order by idx desc";
$query = $query . $where . $order ;
//echo($query);
//exit;
$result = mysql_query($query, $conn);
if(!$result) {
exit;
}
$all = mysql_num_rows($result);
//echo($all);
?>
PHP공부하다 막히는게 있어서 고수님들의 답변을 구하고자 글 올립니다.
소스는 회원DB를 관리자 페이지에서 보여주는건데요 소스보시면 날짜검색해서 볼수있는
sql구문이 있는데 검색은 다 잘되는데 이상하게 당일검색 하면 당일검색이 되질않습니다.
(예를 들면 오늘이 9월5일이라면 9월2일~9월2일 검색실행시 9월2일~9월5일까지 다 나옴)
sql 쿼리문에서 select 설정이 잘못되어서 그런건지...통 알수가 없습니다.혹시 아시는분 답변
부탁드리겠습니다.
그럼 즐건 하루 되세여~
<td valign="top"><BR><div align=center>[ 회원정보 ]</div><BR>
<TABLE border="1" cellpadding="0" cellspacing="0" bordercolor="#999999" width='650' bgColor=#CCCCCC align=center valign="top">
<form name=search action='<?=$PHP_SELF?>' method=POST>
<input type="hidden" name="find" value="1">
<TBODY>
<TR bgcolor="#FFFFFF">
<TD width="57">의뢰인</TD>
<TD colspan='3'>
<input type="text" name="name" value="<?=$name?>"></TD></TR>
<TR bgcolor="#FFFFFF">
<TD>의뢰일자</TD>
<TD colspan='3'>
<? $currentTime = time();
$timeinfo = getdate($currentTime);
if (!$fyear) { $fyear = $timeinfo["year"]; }
if (!$fmonth) { $fmonth = $timeinfo["mon"]; if(strlen($fmonth)==1) { $fmonth = "0" . $fmonth; } }
if (!$fday) { $fday = $timeinfo["mday"]; if(strlen($fday)==1) { $fday = "0" . $fday; } }
if (!$tyear) { $tyear = $timeinfo["year"]; }
if (!$tmonth) { $tmonth = $timeinfo["mon"]; if(strlen($tmonth)==1) { $tmonth = "0" . $tmonth; } }
if (!$tday) { $tday = $timeinfo["mday"]; if(strlen($tday)==1) { $tday = "0" . $tday; } }
if (!$thour) { $thour = date("H"); }
?>
<INPUT size=4 name=fyear value='<?=$fyear?>'>년
<INPUT size=2 name=fmonth value='<?=$fmonth?>'>월
<INPUT size=2 name=fday value='<?=$fday?>'>일 ~
<INPUT size=4 name=tyear value='<?=$tyear?>'>년
<INPUT size=2 name=tmonth value='<?=$tmonth?>'>월
<INPUT size=2 name=tday value='<?=$tday?>'>일
</td></tr>
<tr bgcolor="#FFFFCC">
<td height="17">
<div align="center">AD1</div></td>
<td colspan='3' valign=middle>
<input type="radio" name="mailtype" value="" <? if ($mailtype=="") { ?>checked<? } ?>>전체<input type="radio" name="mailtype" value="1" <? if ($mailtype=="1") { ?>checked<? } ?>>메일1<input type="radio" name="mailtype" value="2" <? if ($mailtype=="2") { ?>checked<? } ?>>메일2<input type="radio" name="mailtype" value="3" <? if ($mailtype=="3") { ?>checked<? } ?>>메일3<input type="radio" name="mailtype" value="4" <? if ($mailtype=="4") { ?>checked<? } ?>>메일4<input type="radio" name="mailtype" value="5" <? if ($mailtype=="5") { ?>checked<? } ?>>
메일5</TD>
</TR>
<tr bgcolor="#FFCCCC">
<td>
<div align="center">AD2</div></td>
<td colspan='3' valign=middle>
<input type="radio" name="mailtype" value="6" <? if ($mailtype=="6") { ?>checked<? } ?>>메일6
<input type="radio" name="mailtype" value="7" <? if ($mailtype=="7") { ?>checked<? } ?>>메일7
<input type="radio" name="mailtype" value="8" <? if ($mailtype=="8") { ?>checked<? } ?>>메일8
<input type="radio" name="mailtype" value="9" <? if ($mailtype=="9") { ?>checked<? } ?>>메일9
<input type="radio" name="mailtype" value="10" <? if ($mailtype=="10") { ?>checked<? } ?>>메일10
<input type="radio" name="mailtype" value="11" <? if ($mailtype=="11") { ?>checked<? } ?>>메일11
<input type="radio" name="mailtype" value="12" <? if ($mailtype=="12") { ?>checked<? } ?>>메일12
<input type="radio" name="mailtype" value="13" <? if ($mailtype=="13") { ?>checked<? } ?>>메일13
<input type="radio" name="mailtype" value="14" <? if ($mailtype=="14") { ?>checked<? } ?>>메일14 </TD>
</TR>
<tr bgcolor="#FFCCCC">
<td>
<div align="center">AD2</div></td>
<td colspan='3' valign=middle>
<input type="radio" name="mailtype" value="15" <? if ($mailtype=="15") { ?>checked<? } ?>>메일15
<input type="radio" name="mailtype" value="16" <? if ($mailtype=="16") { ?>checked<? } ?>>메일16
<input type="radio" name="mailtype" value="17" <? if ($mailtype=="17") { ?>checked<? } ?>>메일17
<input type="radio" name="mailtype" value="18" <? if ($mailtype=="18") { ?>checked<? } ?>>메일18
<input type="radio" name="mailtype" value="19" <? if ($mailtype=="19") { ?>checked<? } ?>>메일19
<input type="radio" name="mailtype" value="20" <? if ($mailtype=="20") { ?>checked<? } ?>>메일20 </TD>
</TR>
<tr bgcolor="#FFFFFF">
<td>처리단계</td>
<td colspan='3' valign=middle>
<input type="radio" name="state" value="" <? if ($state=="") { ?>checked<? } ?>>전체 <input type="radio" name="state" value="N" <? if ($state=="N") { ?>checked<? } ?>>의뢰대기 <input type="radio" name="state" value="Y" <? if ($state=="Y") { ?>checked<? } ?>>의뢰확인</TD></TR>
</TBODY></TABLE> <div align=right>
<INPUT type=button value=' 인쇄 ' style="cursor:hand" onClick="window.print();">
<INPUT type=button value='인쇄보기' style="cursor:hand" onClick="window.open('print.php','print','status=0, menubar=0, scrollbars=yes');">
<INPUT type=reset value='초기화' style="cursor:hand">
<INPUT type=submit value='검색실행' style="cursor:hand"></div>
</form>
<table width="650" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="650" align=center valign="top">
<p><?
$sql_tday = $tday + 1 ;
$query = "SELECT * from event where idx is not null and mailtype <21";
if($name) {
$where .= " and name = '".$name."'" ;
}
if($mailtype) {
$where .= " and mailtype = '".$mailtype."'" ;
}
if($state) {
$where .= " and state = '".$state."'" ;
}
if($find) {
$where .= " and regdate >= '".$fyear . $fmonth . $fday . "' and regdate < '" . $tyear . $tmonth . $sql_tday . "'" ;
}
$order = " order by idx desc";
$query = $query . $where . $order ;
//echo($query);
//exit;
$result = mysql_query($query, $conn);
if(!$result) {
exit;
}
$all = mysql_num_rows($result);
//echo($all);
?>
댓글 전체
//echo($query);
//exit;
sql을 봐주시길 원하신다면 위의 주석을 제거하시어 나온 sql 문을 알려주셔야 합니다.
//exit;
sql을 봐주시길 원하신다면 위의 주석을 제거하시어 나온 sql 문을 알려주셔야 합니다.