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

[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개

댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
2년 전 조회 2,767
2년 전 조회 1,344
2년 전 조회 1,538
2년 전 조회 1,825
2년 전 조회 2,138
2년 전 조회 2,472
2년 전 조회 4,054
2년 전 조회 2,190
2년 전 조회 1,544
2년 전 조회 2,766
2년 전 조회 3,597
2년 전 조회 2,265
2년 전 조회 1,627
2년 전 조회 2,411
2년 전 조회 1,445
2년 전 조회 2,317
2년 전 조회 1,777
2년 전 조회 1,533
2년 전 조회 2,472
2년 전 조회 1,884
2년 전 조회 1,491
2년 전 조회 2,414
2년 전 조회 1,999
2년 전 조회 1,627
2년 전 조회 2,137
2년 전 조회 1,899
2년 전 조회 1,433
2년 전 조회 1,567
2년 전 조회 2,712
2년 전 조회 1,870