아

회원 일간,주간,월간 포인트 회득량 구하기

[code]

   // 사용자의 ID
$user_id = $member['mb_id'];

// 현재 날짜와 시간
$current_date = date("Y-m-d H:i:s");

// 일주월 포인트 계산 함수
function calculatePoint($user_id, $dateRange) {
    global $conn;
    
    $sql = "SELECT SUM(po_point) AS total_point FROM g5_point WHERE mb_id = '$user_id' AND po_datetime >= '$dateRange'";
  
    $result = sql_query($sql);
    
    if ($result) {
        $row = sql_fetch_array($result);
        return $row['total_point'];
    } else {
        return 0;
    }
}

// 일주월 포인트 계산
$one_day_ago = date("Y-m-d H:i:s", strtotime("-1 day", strtotime($current_date)));
$one_week_ago = date("Y-m-d H:i:s", strtotime("-1 week", strtotime($current_date)));
$one_month_ago = date("Y-m-d H:i:s", strtotime("-1 month", strtotime($current_date)));

$daily_point = calculatePoint($user_id, $one_day_ago);
$weekly_point = calculatePoint($user_id, $one_week_ago);
$monthly_point = calculatePoint($user_id, $one_month_ago);

[/code]

 

일:<?=number_format($daily_point)?>

주:<?=number_format($weekly_point)?>

월:<?=number_format($monthly_point)?>

|

댓글 1개

댓글을 작성하시려면 로그인이 필요합니다.
+
제목 글쓴이 날짜 조회
23-10-18 조회 5,953
23-10-17 조회 5,361
23-10-07 조회 7,006
23-10-04 조회 5,800
23-10-03 조회 6,327
23-09-25 조회 6,509
23-09-18 조회 6,665
23-09-18 조회 6,733
23-09-13 조회 8,661
23-09-11 조회 6,550
23-09-06 조회 5,714
23-09-05 조회 7,140
23-09-05 조회 7,947
23-09-01 조회 6,415
23-08-31 조회 5,757
23-08-30 조회 6,729
23-08-25 조회 5,506
23-08-25 조회 6,601
23-08-22 조회 5,904
23-08-21 조회 5,666
23-08-21 조회 6,839
23-08-21 조회 6,058
23-08-20 조회 5,607
23-08-17 조회 6,553
23-08-16 조회 6,160
23-08-16 조회 5,775
23-08-11 조회 6,328
23-08-10 조회 6,050
23-08-07 조회 5,565
23-08-07 조회 5,730