PHP/MySQL | Код генерации матча
php
<?php // вот так тогда генерировала матч function game($first, $second, $mode) { if ($mode == 1){ $bot_first = mysql_fetch_array(mysql_query("select * from football_club_bot where id = '$first' limit 1")); $first = $bot_first['id']; }else{ $bot_first = mysql_fetch_array(mysql_query("select * from football_club where id = '$first' limit 1")); $first = $bot_first['id']; } if ($mode == 1){ $bot_second = mysql_fetch_array(mysql_query("select * from football_club_bot where id = '$second' limit 1")); $second = $bot_second['id']; }else{ $bot_second = mysql_fetch_array(mysql_query("select * from football_club where id = '$second' limit 1")); $second = $bot_second['id']; } $sum_first = mysql_fetch_array(mysql_query("select sum(rating) from football_club_players where club = '$first' and basis = '1'")); $rating_first = $sum_first['0']/11; $sum_second = mysql_fetch_array(mysql_query("select sum(rating) from football_club_players where club = '$second' and basis = '1'")); $rating_second = $sum_second['0']/11; $rand_first = rand(1,5); $rand_second = rand(1,5); $percent_first = $rating_first+$rand_first; $percent_second = $rating_first+$rand_second; if ($percent_first > $percent_second){ $win = $first; $r_score = rand(0,5); $r_sc = rand(1,3); $win_sc = $r_score+$r_sc; $score = $win_sc.' : '.$r_score; } if ($percent_first < $percent_second){ $win = $second; $r_score = rand(0,5); $r_sc = rand(1,3); $win_sc = $r_score+$r_sc; $score = $r_score.' : '.$win_sc; } if ($percent_first == $percent_second){ $win = 0; $r_score = rand(0,5); $score = $r_score.' : '.$r_score; } return $score.'|'.$win; } Стр.: 1, 2

