$rt = mysql_query ( "select count(`id`) from `vikt` where `is`=0" ); $rt = mysql_fetch_row ( $rt ); echo '
' ; $oro = mysql_query ( "select * from `vikt` where `end`<" . time () . " and `is`=0" ); if ( mysql_num_rows ( $oro )!== 0){ while( $roo = mysql_ fetch_assoc ( $oro )){ $oro1 = mysql_query ( "select `sub` from `uch` where `idi`=" .$roo [ 'id' ]); mysql_query ( "update `vikt` set `is`=1 where `id`=" . $roo ['id' ]); $mas =array(); $r = 0 ; while ( $roo1 = mysql_fetch_row ( $oro1 )){ $mas []= $roo1 [0 ]; } $count = count( $mas ); if ( $roo [ 'jack' ]== 0 ) $roo ['jack' ]= $count * $roo [ 'stavka' ]; $re =round ( $roo [ 'jack' ]/ $roo [ 'kol' ]); $cn =round ( $count / $roo [ 'kol' ]); $v = 0 ; $mar =array(); $cn =$cn - 1; for ( $i = 0; $i < $roo ['kol' ]; $i ++){ $v1 = $v + $cn ; $tr = $mas [ mt_rand ( $v , $v1 )]; mysql_query ( "update `uch` set `is`=1 where `sub`= $ tr and `idi`=" .$roo [ 'id' ]); $ty = mysql_query ( "select `balans` from `users` where `id`= $tr " ); $ty = mysql_fetch_assoc ($ty ); $ty = $ty [ 'balans' ]+ $re ; mysql_query ( "update `users` set `balans`= $ ty where `id`= $tr " ); $ty = mysql_query ( 'select `name` from `users` where `id`=' . $tr ); $ty = mysql_fetch_row ( $ty ); $tema ="Молодец!