2009-03-21 4 views
-4

プレーヤーの番号を入力してトーナメントを生成するために、このPHPコードをHTMLに出力するにはどうすればよいですか?このPHPコードをHTMLに出力するにはどうすればよいですか?

<?php 
class RoundRobin 
{ 
var $MaxTeams; 
var $MaxCombinations; 
var $tourn; 
var $mList; 
var $cList; 
var $cUsed; 
function RoundRobin($max) 
{ 
    $this->MaxTeams=$max; 
    $this->MaxCombinations=($this->MaxTeams/2)*($this->MaxTeams-1); 
} 
function ShowSchedule($players,$totalChecks) 
{ 
    echo $players.' players'."\n"; 
    for ($r=1; $r <= $players/2; $r++) echo 'Game'.$r; 
    echo "\n"; 
    echo"  +-"; 
    for ($r=1; $r <= ($players/2)*6-2; $r++) echo '-'; 
    echo "\n"; 
    $index = 1; 
    for ($r=1; $r <= $players-1; $r++) 
    { 
    echo 'Week '.$r. '|'; 
    for ($m=1; $m <= $players/2; $m++) 
    { 
     echo $this->tourn[$index]['one'].'&amp;'. $this->tourn[$index]['two']; 
     $index++; 
    } 
    echo "\n"; 
    } 
    echo "\n".$totalChecks,' combinations tried'. "\n\n"; 
} 
function array_copy(&$dest,$source) 
{ 
    if(count($source)>count($dest)) {echo 'fatal'; exit;} 
    //for($a=0;$a<count($source);$a++) 
    $dest['one']=$source['one']; 
    $dest['two']=$source['two']; 
} 
function ClearArrays() 
{ 
    for ($i=0; $i <= $this->MaxCombinations; $i++) 
    { 
    $this->tourn[$i]['one']=0; 
    $this->tourn[$i]['two']=0; 
    $this->cList[$i]['one']=0; 
    $this->cList[$i]['two']=0; 
    $this->cUsed[$i]=0; 
    if($i<=$this->MaxTeams/2)$this->mList[$i] = 0; 
    } 
} 
function Scheldule($players) 
{ 
    while ($players <= $this->MaxTeams) 
    { 
$combinations = $players/2 * ($players-1); 
    $totalChecks = 0; 
$this->ClearArrays(); 
    /* set up list of all combinations */ 
    $m=1; 
    for ($a=1; $a<$players; $a++) 
     for ($b=$a+1; $b<=$players; $b++) 
     { 
     $this->cList[$m]['one'] = $a; 
     $this->cList[$m]['two'] = $b; 
     $m++; 
     } 
    $roundCount=1; 
    $index=1; 
    while ($roundCount <= $players-1) 
    { 
     $matchCount = 1; 
     $round_set = 0; 
     for ($i=0; $i<=$this->MaxTeams/2; $i++) $this->mList[$i] = 0; 
     $startC = $roundCount; 
     while ($matchCount <= $players/2) 
     { 
      $c = $combinations + 1; 
      while ($c > $combinations) 
      { 
       $c = $startC; 
       /* find an unused pair that would be legitimate */ 
       while (
       ($c <= $combinations) 
       && 
         (// 
         ($round_set & (1 << $this->cList[$c]['one'])) || 
         ($round_set & (1 << $this->cList[$c]['two'])) || 
         (!empty($this->cUsed[$c])) 
        ) 
        ) $c++; 
       if ($c > $combinations) 
       { 
        do { 
        $this->mList[$matchCount] = 0; 
        $matchCount--; 
        $index--; 
        $round_set &= ~(1 << $this->cList[$this->mList[$matchCount]]['one']); 
        $round_set &= ~(1 << $this->cList[$this->mList[$matchCount]]['two']); 
        $this->cUsed[$this->mList[$matchCount]] = false; 
        $this->tourn[$index]['one'] = 0; 
        $this->tourn[$index]['two'] = 0; 
        } 
        while ($this->cList[$this->mList[$matchCount]]['one'] != $this->cList[$this->mList[$matchCount]+1]['one']); 
        $startC = $this->mList[$matchCount]+1; 
       } 
      } 
      $this->array_copy(&$this->tourn[$index],$this->cList[$c]); 
      $totalChecks++; 
      if (($totalChecks % 1000) == 0) printf("%d\033A\n", $totalChecks); 
      $this->cUsed[$c] = true; 
      $this->mList[$matchCount] = $c; 
      $startC = 1; 
      $round_set |= (1 << $this->cList[$c]['one']); 
      $round_set |= (1 << $this->cList[$c]['two']); 
      $index++; 
      $matchCount++; 
     } 
     $roundCount++; 
    } 
    /* yahoo!, scheduled all the rounds */ 
    printf("   "); 
    $this->ShowSchedule($players,$totalChecks); 
    /* try and make a schedule using two more teams */ 
    $players += 2; 
    } 
    } 
} 
?> 
+0

だから...質問は何ですか?このスクリプトに投稿するためにHTMLを書くには?つまり、そのintrincateスクリプトをどのようにコードするのか知っていますが、単純なHTMLフォームを書く方法はわかりません。 – Seb

+0

質問を詳しく説明し、貼り付けているコードを減らしてください – vartec

+0

私はそれを書いていませんでした。私は友達から手に入れました。私はそれを実行しようとしますが、うまくいきませんでした。それは私が求めている理由です。 – Siva

答えて

2

これはPHPクラスです。読書the manualがお手伝いします。このかもしれない作業のラインに沿って

何か:

$rr = new RoundRobin(5); 

$rr->Scheldule($_POST['PlayerCount']); 

しかし、私はそれが本当にないかどう動作するようにコードを解読気にすることはできません。

また、まだHTMLフォームを学習していない場合は、w3schoolsのようなチュートリアルを読んでください。

+0

笑...私はhtmlをする方法を知っています...しかし、それは仕事をしなかった..私は尋ねた – Siva

関連する問題