在给出排名时添加积分

时间:2015-07-29 11:20:12

标签: php mysql

是的,所以我有一个促销按钮设置。有人收到的每个促销活动都会给他们提供积分,但每个等级都有不同的分数,具体取决于它的高低或高低。我很难弄清楚如何通过他们的排名来获得积分。我的数据库列称为:rank和rank在数据库中称为数字,当它在外部显示时,它们都具有函数的名称。所以即;等级1,2,3,4等于Noob,会员,精英,上帝。无论如何,如果你能帮助我找出我的错误,那将是伟大的,有点新的PHP。我遇到的问题是没有给予该人这些要点。他们得到提升,但没有分数。

promote.php

    <?php include_once('../classes/check.class.php'); ?>
<?php  include('../config/db.php'); ?>
<?php include('functionsprom.php'); ?>
<?php if( protectThis("1, 2, 3") ) : ?>
<?php

 if (isset($_GET['id']) && is_numeric($_GET['id']))
 {
 $id = $_GET['id'];
 $date = date('d M y');
 $prom = promote;
 $result = mysql_query("UPDATE players SET date='$date', rank = rank + 1, exp = exp + '$prom' WHERE id=$id", $db1)
 or die(mysql_error()); 

    require_once("../config/logdb.php");
 include('../logs.php');
 write_mysql_log($promote, $db);


 header("Location: ../home.php");
 }
 else
 {
 header("Location: home.php");
 }

?>
    <?php endif; ?> 

functionsprom.php

    <?php
include('functionsrank.php');
mysql_select_db('pts_player');

$rank = "SELECT rank FROM players WHERE id = $id";

    function promote($rank) {
    if($rank == 1):
    $prom = 0;
    elseif($rank == 2):
    $prom = 0;
    elseif($rank == 3):
    $prom = 0;
    elseif($rank == 4 ):
    $prom = 10;
    elseif($rank == 5):
    $prom = 20;
    elseif($rank == 6):
    $prom = 30;
    elseif($rank == 7):
    $prom = 45;
    elseif($rank == 8):
    $prom = 45;
    elseif($rank == 9):
    $prom = 55;
    elseif($rank == 10):
    $prom = 60;
    elseif($rank == 11):
    $prom = 75;
    elseif($rank == 12):
    $prom = 75;
    elseif($rank == 13):
    $prom = 0;
    elseif($rank == 14):
    $prom = 0;
    elseif($rank == 15):
    $prom = 100;
    elseif($rank == 16):
    $prom = 200;
    elseif($rank == 17):
    $prom = 400;
    elseif($rank == 18):
    $prom = 600;
    elseif($rank == 19):
    $prom = 800;
    elseif($rank == 20):
    $prom = 900;
    elseif($rank == 21):
    $prom = 1000;
    elseif($rank == 22):
    $prom = 1200;
    elseif($rank == 23):
    $prom = 1400;
    elseif($rank == 24):
    $prom = 0;
    endif;
    return $rank;
    }
?>

0 个答案:

没有答案