主题:  php+mysql的游戏积分榜接口程序

Demon.S

职务:版主
等级:5
金币:10.0
发贴:2468
注册:2000/9/15 13:56:49
#12001/3/17 16:27:29
///////////Programed by Demon.S a free code
///////////You can use it in your scoreboard-programe,there are 2 action "pushdata","getdata"
///////////that you must transform to here,and also vars like "name","score" must trans to ///////////here(when you wanna push data),result will be returned a pushed=ok or getedXX,max ///////////spefics a var that the max num you want display.
///////////需要传递的变量是pushdata或者是getdata,pushdata的时候也需要传递name,score,push返回值是
///////////pushed=ok,get的返回值是getedxx.
///////////thanx for useing my code.

//initiat
$server="your server";
$user="user";
$pass="password";
//prepare
$pushed=mysql_connect($server,$user,$pass);
if (!$pushed){
echo "database error.";
}
$pushed=mysql_select_db("score");
if (!$pushed){
echo "select error.";
}

//push
if ($action=="pushdata"){
$query="insert into userscore (name,date,score) values ('$name',now(),'$score')";
$pushed=mysql_query($query);
if (!$pushed){
echo "insert error.";
}else{
echo "&pushed=ok";
}
}

//get
if ($action=="getdata"){
$max=10;
$query="select * from userscore";
$geted=mysql_query($query);
$geted_num=mysql_fetch_row($geted);
$num=count($geted_num)
for ($i=0;$i<$num-1;$i++){
for ($j=$i+1;$j<$num;$j++){
    if ($geted_num[$i]<$geted_num[$j]){
        $temp=$geted_num[$i};
        $geted_num[$i]=$geted_num[$j];
        $geted_num[$j]=$temp;
    }
}
}
//output
for {$i=0;$i<$max;$i++){
    echo ("&geted".$i.$geted_num[$i]);
}
?>

环境,php+mysql



semon

职务:普通成员
等级:3
金币:1.0
发贴:896
注册:2000/9/15 13:43:14
#22001/3/18 17:42:46
表呢?



Demon.S

职务:版主
等级:5
金币:10.0
发贴:2468
注册:2000/9/15 13:56:49
#32001/3/18 19:15:57
接口而已,作为资料参考参考吧。