아

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

[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,964
23-10-17 조회 5,368
23-10-07 조회 7,018
23-10-04 조회 5,811
23-10-03 조회 6,338
23-09-25 조회 6,516
23-09-18 조회 6,674
23-09-18 조회 6,746
23-09-13 조회 8,670
23-09-11 조회 6,559
23-09-06 조회 5,721
23-09-05 조회 7,152
23-09-05 조회 7,956
23-09-01 조회 6,423
23-08-31 조회 5,765
23-08-30 조회 6,735
23-08-25 조회 5,514
23-08-25 조회 6,609
23-08-22 조회 5,913
23-08-21 조회 5,670
23-08-21 조회 6,844
23-08-21 조회 6,062
23-08-20 조회 5,610
23-08-17 조회 6,561
23-08-16 조회 6,166
23-08-16 조회 5,786
23-08-11 조회 6,336
23-08-10 조회 6,056
23-08-07 조회 5,570
23-08-07 조회 5,739