Announcement

Collapse
No announcement yet.

Problems with displaying incremental variables....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with displaying incremental variables....

    Code:
    for ($i = 2 ; $i < $cct2->players->count ; $i++)
       {
       $cct2players = $cct2->players->field0[$i];
       $cct2playerteam = $cct2->players->field3[$i];
       $cct2playerscore = $cct2->players->field1[$i];
    }
    This by rights should display about 20 players at the moment, but only shows the last player.

    It works in raw PHP in a single page, it displays all the players, teams, and scores, but when put into the Vbulletin PHP Parsed Code Template it only displays the last player, skipping all the ones previous.

    Am I missing something silly here ???

  • #2
    Well, you're just overwriting the same variable 20 times. Hence only the last stays.

    Comment


    • #3
      Ok ... Since I am a PHP Newbie ... is there a way to display the variables in Vbulletin without having to write each variable for each player (up to 64 players, hence 64X3 variables)

      *sigh*

      I think I will have to do a variable for each player ... I hope not, think of the excess overhead.

      Comment


      • #4
        Arrays or ".=" instead of "=" . I have no clue what you're trying to do, but this is probably how I'd do it:

        Code:
        for ($i = 2 ; $i < $cct2->players->count ; $i++)
           {
           $cct2players[]['something'] = $cct2->players->field0[$i];
           $cct2players[]['team'] = $cct2->players->field3[$i];
           $cct2players[]['score'] = $cct2->players->field1[$i];
        }

        Comment


        • #5
          Its a Tribes2 Qstat Output

          The players, their score, and team are output raw from qstat like this ...

          Code:
          Herracon Eagle,,,0,,,0,,,TEAM,,,,,,
          Dragon Blade,,,0,,,1,,,TEAM,,,,,,
          Player1,,,0,,,1,,,Player,,,Bot,,,
          Player2,,,0,,,1,,,Player,,,Bot,,,
          etc
          etc
          Player1 = Field0[3]
          Player2 = Field0[4]

          i.e the field increases by one number for each line.

          I have a qstat.inc which does the explode (sorting the variables from the ,,, seperators).

          Normally I just
          Code:
          for ($i = 2 ; $i < $cct2->players->count ; $i++)
             {
             echo $cct2->players->field0[$i];
             echo $cct2->players->field3[$i];
             echo $cct2->players->field1[$i];
          }
          But Vbulletin wont allow direct echoing, so I have to find some way to recursively read, and display each variable incrementally.

          I hope that clears up my goal.

          Comment


          • #6
            Replace the "echo" with $stats .=

            Then reference $stats where you want it in your header.

            Comment


            • #7
              Ahhh Excellent ... Thanks very much for you help Ed

              Comment

              Loading...
              Working...
              X