for문 , 쿼리문 질문입니다ㅠㅠㅠ
본문
$que_sum = "
SELECT
MID(wr_subject, 6, 2)
wr_61 AS wr61,
wr_62 AS wr62,
sum(wr_63) AS sum63,
sum(wr_64) AS sum64,
sum(wr_81) AS sum81
FROM
g5_write_811
GROUP BY
LEFT(wr_subject, 7)
ORDER BY
date DESC
;
";
$rs_sum = sql_query($que_sum);
for($i=0; $row_sum = sql_fetch_array($rs_sum); $i++){
?>
<th style="text-align:center;"><b><?=$row_sum['date']?>월</b></th>
<td style="text-align:center;"><?=$row_sum['wr61']?></td>
<td style="text-align:center;"><?=$row_sum['wr62']?></td>
<?}?>
[/code] *wr_subject(날짜 2018-01-01 형식) 현재 이렇 반복문을 돌려서 월별 합계를 나타고
있는데요.. 저렇게 for문을 sql 문을 주고 돌리면 date는 데이터가 등록되어있는 월 만 표기하게 for문이
돌아가는데요 저 소스를 월별로 말고
일별로 하는 방법은 없을까요..?
오늘이 15일이면 1일 부터 15일 까지만 나와는 방법과
1~31일까지 쭉 나오게 하는 방법은없을까요?
!-->
답변 2
일별
SELECT
MID(wr_subject, 9, 2)
wr_61 AS wr61,
wr_62 AS wr62,
sum(wr_63) AS sum63,
sum(wr_64) AS sum64,
sum(wr_81) AS sum81
FROM
g5_write_811
GROUP BY
LEFT(wr_subject, 9)
그후에 if문으로 일별체크를 통해 break; 하시면될듯싶네요
$que_sum = "
SELECT
MID(wr_subject, 6, 2)
wr_61 AS wr61,
wr_62 AS wr62,
sum(wr_63) AS sum63,
sum(wr_64) AS sum64,
sum(wr_81) AS sum81
FROM
g5_write_811
GROUP BY
LEFT(wr_subject, 9)
HAVING wr_subject between '".date("Y-m-01")."' and '".date("Y-m-d")."'
ORDER BY
date DESC;";
밑줄 친 부분을 넣으시면 첫번째 방법이 처리되고, 뒤에 Y-m-d를 Y-m-31로 바꾸면 두번째 방법이 처리되겠네요
!-->
답변을 작성하시기 전에 로그인 해주세요.