검색관련되서 질문드립니다~ 정보
검색관련되서 질문드립니다~본문
댓글 전체
예제 폼 태그소스를 보여줘야 답줄수 있을거같네요
모든조건을 가진 조건검색이 아니고 결과물 검색을 말하는듯 보입니다.
제가 며칠전에 모업체에 만들어준 결과물내 재검색 방법인데 참고가 되실런지 모르겠습니다.
$sql_common = " from $g4[makesop_table] ";
$sql_search = " where (1) ";
if ($sop_cm1) {
$sql_search .= " and ( ";
$sql_search .= " (sop_m1 = '$sop_cm1') ";
$sql_search .= " ) ";
}
if ($sop_cm6) {
$sql_search .= " and ( ";
$sql_search .= " (sop_m6 = '$sop_cm6') ";
$sql_search .= " ) ";
}
if ($mdata) {
$sql_search .= " and ( ";
$sql_search .= " ($mdata <= $sop_sm11 and $mdata >= $sop_bm11) ";
$sql_search .= " ) ";
}
if ($stx) {
$sql_search .= " and ( ";
if ($sfl) {
$sql_search .= " ($sfl like '$stx%') ";
}
if (!$sfl) {
$sql_search .= " (sop_m1 like '$stx%') ";
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "sop_id";
$sod = "desc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt
$sql_common
$sql_search
$sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows =20;
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select *
$sql_common
$sql_search
$sql_order
limit $from_record, $rows ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
//내용출력
}
$sql_common = " from $g4[makesop_table] ";
$sql_search = " where (1) ";
if ($sop_cm1) {
$sql_search .= " and ( ";
$sql_search .= " (sop_m1 = '$sop_cm1') ";
$sql_search .= " ) ";
}
if ($sop_cm6) {
$sql_search .= " and ( ";
$sql_search .= " (sop_m6 = '$sop_cm6') ";
$sql_search .= " ) ";
}
if ($mdata) {
$sql_search .= " and ( ";
$sql_search .= " ($mdata <= $sop_sm11 and $mdata >= $sop_bm11) ";
$sql_search .= " ) ";
}
if ($stx) {
$sql_search .= " and ( ";
if ($sfl) {
$sql_search .= " ($sfl like '$stx%') ";
}
if (!$sfl) {
$sql_search .= " (sop_m1 like '$stx%') ";
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "sop_id";
$sod = "desc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt
$sql_common
$sql_search
$sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows =20;
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select *
$sql_common
$sql_search
$sql_order
limit $from_record, $rows ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
//내용출력
}