아

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

· 2023-08-25 (금) 23:58:59 · 4319 · 1

[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,790건
+
제목 글쓴이 날짜 조회
23-10-07 조회 5,755
23-10-04 조회 4,369
23-10-03 조회 4,805
23-09-25 조회 5,083
23-09-18 조회 5,361
23-09-18 조회 5,474
23-09-13 조회 7,433
23-09-11 조회 5,354
23-09-06 조회 4,525
23-09-05 조회 5,967
23-09-05 조회 6,713
23-09-01 조회 5,226
23-08-31 조회 4,562
23-08-30 조회 5,504
23-08-25 조회 4,320
23-08-25 조회 5,391
23-08-22 조회 4,722
23-08-21 조회 4,506
23-08-21 조회 5,632
23-08-21 조회 4,898
23-08-20 조회 4,409
23-08-17 조회 5,403
23-08-16 조회 4,973
23-08-16 조회 4,588
23-08-11 조회 5,136
23-08-10 조회 4,921
23-08-07 조회 4,414
23-08-07 조회 4,559
23-08-03 조회 5,846
23-08-03 조회 4,882