循环内自动递增

时间:2012-12-24 21:43:56

标签: php

我需要在while循环内自动递增数组值。如果数组值为$Values[2],我需要在下一个循环中为$Values[3]。我所拥有的并没有提供任何结果。

//select the top spread winners
$query_moline = "SELECT * FROM `highscore_leader` WHERE `game_id`=\"$game_id\" AND `leader_id`<>\"$curmemid\" AND `score`>\"$myscore\" AND `active`='Y' ORDER BY `score` DESC LIMIT \"$top_payout\"";
$moline = mysql_query($query_moline) or die(mysql_error());
$row_moline = mysql_fetch_assoc($moline);
$totalRows_moline = mysql_num_rows($moline);

$index=$top_payout;
static $i=2;

do {

$score_id=$row_moline['id'];
$player_id=$row_moline['leader_id'];

if($totalRows_moline>0){
foreach ($row_moline['id'] as $scoreid)
     {
        $i++;
     }
$player_comission=$values[$i];
//update payout tables
$strsql="UPDATE `ttourmember` SET `accountamount`=(`accountamount`+\"$player_comission\") WHERE `memberid`=\"$player_id\"";
mysql_query($strsql,$connect) or die(mysql_error());
$chkrow3=mysql_affected_rows($connect); 

}} while ($row_moline = mysql_fetch_assoc($moline));

1 个答案:

答案 0 :(得分:0)

//select the top spread winners

$query_moline = "SELECT * FROM `highscore_leader` WHERE `game_id`=\"$game_id\" AND `leader_id`<>\"$curmemid\" AND `score`>\"$myscore\" AND `active`='Y' ORDER BY `score` DESC LIMIT \"$top_payout\"";
$moline = mysql_query($query_moline) or die(mysql_error());
$totalRows_moline = mysql_num_rows($moline);

$index=$top_payout;
static $i=2;
$i = 0;

if($totalRows_moline>0)
{
    while($row_moline = mysql_fetch_assoc($moline)) 
    {    
        $score_id=$row_moline['id'];
        $player_id=$row_moline['leader_id'];

        $player_comission=$values[$i];
        //update payout tables
        $strsql="UPDATE `ttourmember` SET `accountamount`=  (`accountamount`+\"$player_comission\") WHERE `memberid`=\"$player_id\"";
        mysql_query($strsql,$connect) or die(mysql_error());
        $chkrow3=mysql_affected_rows($connect); 
        $i++;
    }
} 

抱歉格式化..在手机上!有人可以帮忙解决!