select박스 날짜 DB연동 질문 채택완료
니냐노
3년 전
조회 2,276

현재 이미지 아랫부분에 월간매출의 input박스를 셀렉트 박스를 이용해서

기간을 정해놔서 DB를 불러오게 하려고 하는데
db를 어떻게 해야될지 모르겟습니다
[CODE]
$sql = "SELECT SUM(ct_price) as total_pay,
SUBSTRING(ct_time,1,7) as ctDt,
SUM(IF(at_status, 0, ct_price)) as x_pay,
SUM(at_price) as already_pay,
COUNT(*) as cnt
FROM `g5_shop_cart` cart JOIN g5_shop_item itm ON cart.it_id = itm.it_id
WHERE itm.it_2_subj ='{$member["mb_id"]}' AND at_status=0";
if ($_GET["fr_month"]) {
$fr_date = $_GET["fr_month"];
$to_date = $_GET["to_month"];
$sql.= " AND SUBSTRING(ct_time,1,7) between '$fr_date' AND '$to_date' ";
$qstr = "fr_date=$fr_date&to_date=$to_date";
}
$result = sql_query($sql, true);
?>
[/CODE]
1.option value 값을 date("Y01", G5_SERVER_TIME)를 사용해야되는데 년 값과 월 값을 어떻게 가져와야되는지
2. $fr_date = $_GET["fr_month"]; $to_date = $_GET["to_month"];
////////////////////////////////
AND SUBSTRING(ct_time,1,7) between '$fr_date' AND '$to_date' ";
의 between 을 수정해야될것같은데 어떻게 수정을 해야되는지 여쭙고 싶습니다
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
3년 전
</p>
<p>
$sql = "SELECT SUM(ct_price) as total_pay,
SUBSTRING(ct_time,1,7) as ctDt,
SUM(IF(at_status, 0, ct_price)) as x_pay,
SUM(at_price) as already_pay,
COUNT(*) as cnt
FROM `g5_shop_cart` cart JOIN g5_shop_item itm ON cart.it_id = itm.it_id
WHERE itm.it_2_subj ='{$member["mb_id"]}' AND at_status=0";</p>
<p>
if ($_GET["s_year"] != "" && $_GET["s_month"]) {
$s_date = $_GET["s_year"]."-".$_GET["s_month"];
$sql.= " AND SUBSTRING(ct_time,1,7) = '$s_date' ";
$qstr = "s_year=$s_year&s_month=$s_month";
}</p>
<p>$result = sql_query($sql, true);
?></p>
<p><?php print_r($sql) ?></p>
<p>
<div>
<form name="frm_month" action="" method="get">
<strong>기간</strong>
<select name="s_year" onChange="this.form.submir();">
<option value="2022">2022년</option>
</select>
<select name="s_month" onChange="this.form.submir();">
<?php for($i=1; $i<=12; $i++){ ?>
<option value="<?=$i?>"><?= $i?>월</option>";
<? }
?>
</select></p>
<p> </form></p>
<p></div>
</p>
<p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
�
니냐노
3년 전
감사합니다 ~ 명쾌한 답변이엇습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인