728x90
반응형
$sort1 = $_GET['sort1'];
$sort2 = $_GET['sort2'];
$page = $_GET['page'];
if (!$to_date) $to_date = date("Ymd", time());
if ($sort1 == "") $sort1 = "ct_status_sum"; //기본 배열
if (!in_array($sort1, array(WHERE로 넣을 컬럼명을 배열로 작성해준다))) $sort1 = "ct_status_sum";
if ($sort2 == "" || $sort2 != "asc") $sort2 = "desc";
$sort1 = strip_tags($sort1);
if( preg_match("/[^0-9]/", $fr_date) ) $fr_date = '';
if( preg_match("/[^0-9]/", $to_date) ) $to_date = '';
$sql =쿼리문~~
$sql .= " order by $sort1 $sort2 ";
$result = $con->query($sql);
728x90
반응형