我正在使用 UNITY 创建一个游戏,它是 PHP bla bla... 你我有一些小事情需要弄清楚才能对行进行排序。问题是——这是一款我需要对玩家进行分类的游戏。例如,如果玩家 3 离开/离开游戏,那么玩家 3 的 uid 为 2
那么我们只有玩家 1 玩家 2 和玩家 4 他们有 0 1 3
player1 = 0
player2 = 1
player3 = 2
player4 = 3
所以我需要做的就是把它整理出来,所以如果player3 left uid 2
我需要做整理,它会这样
player4 = 3
player2 = 1
player1 = 0
我使用了sort( $row = mysql_fetch_array( $sql ) )
但我只得到了错误我也使用了sort( $row['players'] );
$row['players']
这是0 1 2 3
但它没有对我需要的东西进行排序但它的输出是这个
player1 = 3
player2 = 1
player4 = 0
这是错误的,现在玩家和当前玩家不相等
帮帮我,什么应该是正确的代码
我希望每个人都明白我需要在这里解决什么。
我也尝试使用 ORDER BY player DESC,但效果不佳。我知道有一些更具体的订购。
我有更多解释,这是我需要解决的顺序/排序。
GameID Turn
3 2
6 1
7 2
5 2
8 0
9 1
return should be { for example GameID 6 is TURN for the Game or Left in the Game }
GameID Turn
6 1
9 1
8 0
3 2
5 2
7 2
another example { for example GameID 7 is TURN for the Game or Left in the Game }
GameID Turn
7 2
3 2
5 2
8 0
9 1
6 1
这是我的查询
$email_val = email@sample.com';
if( $email_val != null ){
$sqlCheckError = mysql_query( "SELECT * FROM game WHERE player1 = '".$email_val."' || player2 = '".$email_val."' || player3 = '".$email_val."' || player4 = '".$email_val."' " ) or die ( mysql_error() );
$gameCheck = mysql_fetch_array($sqlCheckError);
// CHECK FOR GAMEID ERROR
$gameIDCheck = $gameCheck['gameID'];
// EMAIL EQUAL TO THE CURRENTTURN WHERE ID
$sql = mysql_query( "SELECT * FROM game WHERE player1 = '" . $email_val . "' || player2 = '".$email_val."' || player3 = '".$email_val."' || player4 = '".$email_val."' " ) or die ( mysql_error() );
// FIXED THE SORT OF
while ( $row = mysql_fetch_array( $sql ) ) {
$p1 = $row['player1'];
$p2 = $row['player2'];
$p3 = $row['player3'];
$p4 = $row['player4'];
if ($asterisk > 0) {
echo "*";
}
echo $row['gameID'] . '|';
echo $row['gameStatus'] . '|';
echo $getNameLower->_NAME_LOWER_PLAYER_ONE_( $p1 );
echo $getNameLower->_NAME_LOWER_PLAYER_TWO_( $p2 );
if ( !empty( $p3 ) ){
echo $getNameLower->_NAME_LOWER_PLAYER_THR_( $p3 );
} else {
echo '';
}
if ( !empty( $p4) ){
echo $getNameLower->_NAME_LOWER_PLAYER_FOU_( $p4 );
} else {
echo '';
}
echo '|' . $row['start'];
echo '|' . $row['currentTurn'];
echo '|' . $row['lastWord'];
echo '|' . $row['lastPlayer'];
echo '|' . $row['lastPoints'];
$cur = $row['currentTurn'];
// CHECK THE CurrentTurn then PUT IT AS PICURL
if ( $cur == '0' ) { echo $getPIC->purl_1( $p1 ); }
elseif( $cur == '1' ) { echo $getPIC->purl_2( $p2 ); }
elseif( $cur == '2' ) { echo $getPIC->purl_3( $p3 ); }
elseif( $cur == '3' ) { echo $getPIC->purl_4( $p4 ); }
$asterisk++;
}
if( $gameIDCheck == null ){
echo '0';
}
}
else{
echo '0';
}
是的,我已经首先想到了。Order By 真的很容易对所有内容进行排序。但它不会像这样 2 0 1 排序,1 2 0
因此,如果我们使用 ORDER BY DESC 2 1 0 和 ASC 0 1 2 我希望它现在清楚