제발도와주세요

2022-12-29 (목) 15:58:05 1,399

검색에 관해서

이름을 검색을 하였든,
조건을 걸어 날짜를 검색을 하였든

날짜 검색 후 등록/보류/삭제 처리를 해도 기존 검색 조건 그대로 남아있도록 어떠한 식으로 풀어야할까요?

보통 페이지를 넘겨서 처리를하고 다시 돌아오는 그러한 식으로 코드를짰는데..

어떠한것을 검색을 했음 남아있도록 메인페이지 다시 눌렀을때 없어지게 하고싶어요

해당버전은 5.2 v 입니다.

============================보류 버튼

function hold() {       

         

        const checked = document.querySelectorAll('[name="url_num"]:checked');

            if ( !checked.length ) {

                    alert("보류할 대상을 체크 해주세요.");

                    return false;

                } //check된것을 가져오나 확인차.

            let form = document.createElement("form");

            form.method = "POST";

            form.action = "list_hold.php";

            let input = document.createElement("input");

            input.type = "hidden";

            input.name = "data";

            input.value = Array.from(checked).map(o=>o.value).join(",");

            form.appendChild(input);

            document.body.appendChild(form);

            form.submit();

            alert("보류 되었습니다.");

    }

============================

============================넘어온 list_hold.php 페이지

<?php

    include 'inc_head.php';   

    include 'connect.php';   

?>

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8" />

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />       

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

<?php

     

    if(isset($_POST['data'])){

        // $data = $_POST['data'];      

        $data = isset($_POST['data']) ? $_POST['data'] : '';

            if ( !preg_match('/^[0-9,]+$/', $data) ) exit('<script>alert("선택값 없음");history.back();</script>');

        $temp = preg_split('/,/', $data, -1, 1); // 콤마로 분리, 빈 배열 제외

            if ( !count($temp) ) exit('<script>alert("선택값 없음");history.back();</script>');

            $val = implode(',', $temp); // 숫자만 남아있으니 콤마로 결합

        $sql = "update admin.tb_bizring set biz_flag = '보류' WHERE biz_key IN ({$val})";

        $result = $connect->query($sql);

        // var_dump($data, $sql);

         

    }

     

    echo "<script>

    document.location.href = 'list.php';       

    </script>";

     

    exit;

     

     

    ?>

</head>

</html>

============================ 메인 페이지 날짜 검색 else if 및 이름 검색

 $date_to =  $_POST['date_to'];

        $date_from = $_POST['date_from'];

        // ex) 11-30 ~ 11-29 눌렀을때 변수

        $str_now = strtotime($date_to);

        $str_target = strtotime($date_from);

        // ex) 11-30 ~ 11-29 눌렀을때 Alert창

        if ($str_now > $str_target) {

                echo "<script>

                    alert('잘못된 접근입니다. 날짜를 다시 확인해주세요.');                   

                </script>";

                echo "<script>

                    document.location.href = 'detail_list.php';

                </script>";

            exit; //빠져 나오기

        }

    if(isset($_POST['search'])){

        $catagory = $_POST['catgo'];

        $search_con = $_POST['search'];       

        $sql = "select

                    IFNULL(biz_key, '0') as biz_key,

                    IFNULL(biz_type, '0') as biz_type,

                    IFNULL(biz_name, '0') as biz_name,

                    IFNULL(biz_rc, '0') as biz_rc,

                    IFNULL(biz_phonecorp, '0') as biz_phonecorp,

                    IFNULL(biz_phone, '0') as biz_phone ,

                    IFNULL(biz_birth, '0') as biz_birth,

                    IFNULL(biz_gender, '0') as biz_gender,

                    IFNULL(biz_regtime, '0') as biz_regtime,

                    IFNULL(biz_flag, '0') as biz_flag

                from admin.tb_bizring where $catagory like '%$search_con%' and biz_type = '간편'

                order by biz_regtime desc";

    } else if($date_to && $date_from){

        $sql = "select 

                IFNULL(biz_key, '0') as biz_key,

                IFNULL(biz_type, '0') as biz_type,

                IFNULL(biz_name, '0') as biz_name,

                IFNULL(biz_rc, '0') as biz_rc,

                IFNULL(biz_phonecorp, '0') as biz_phonecorp,

                IFNULL(biz_phone, '0') as biz_phone,

                IFNULL(biz_birth, '0') as biz_birth,

                IFNULL(biz_gender, '0') as biz_gender,

                IFNULL(biz_regtime, '0') as biz_regtime,

                IFNULL(biz_flag, '0') as biz_flag

             

            FROM admin.tb_bizring

            WHERE biz_regtime BETWEEN '$date_to 00:00:00' AND '$date_from 23:59:59'

    ORDER BY biz_regtime DESC";

    }

|

답변 2개

만약 메인페이지로 가기전까지는 검색한 값을 계속 가지고 계시려면 세션에 저장하세요

메인페이지에서 세션을 지우면되구요

2022-12-30 (금) 06:25:35

ajax로 처리하시거나

모든 검색 조건 값을 처리 페이지에도 넘겨 주시고

페이지 이동할 때 이 값을 사용해서

 페이지 이동하게 하면 됩나다

답변을 작성하려면 로그인이 필요합니다.