Jump to content

poweredbyaces

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

poweredbyaces's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ive tried both versions of what you guys posted and neither has worked.  Which is why i posted the entire version of the code to see if something else was interfering...
  2. ive tried [], ive tried [''] ive tried [""]  no difference.  Heres the code as is: <? class Team { var $teamid; var $teamname; var $mascot; var $ratings=array(); function PlayerName ( $which , $spot ){ if($which=="position"){ echo $this->ratings[$spot][name]; } else { echo $this->ratings[batorder][$spot][name]; } } function GetInfo ( $teamid ){ $this->$teamid = $teamid; $sql = "SELECT * FROM teams WHERE `index`='$teamid'"; $result = @mysql_query($sql) or die("couldn't execute query $sql.".mysql_error().mysql_error()); while($row = mysql_fetch_array($result)) { $this->teamname=$row{'name'}; $this->mascot=$row{'mascot'}; } $c=0; $if=0; $of=0; $order=0; $sql = "SELECT * FROM players WHERE `team`='$teamid' && `pos`!='P' order by `order`"; $result = @mysql_query($sql) or die("couldn't execute query $sql.".mysql_error().mysql_error()); while($row = mysql_fetch_array($result)) { $plid=$row{'index'}; $name=$row{'firstname'}. " " . $row{'lastname'}; $age=$row{'age'}; $pos=$row{'pos'}; $mypos=""; if($pos=="C"){ $count=0; $sqlb = "SELECT * FROM players WHERE `team`='$teamid' && `pos`='C' order by `fielding`"; $resultb = @mysql_query($sqlb) or die("couldn't execute query $sql.".mysql_error().mysql_error()); while($rowb = mysql_fetch_array($resultb)) { $count++; if($rowb{'index'}==$plid){ $c=$count; } } if($c==1){ $mypos="catcher"; $order++; } } if($pos=="IF"){ $count=0; $sqlb = "SELECT * FROM players WHERE `team`='$teamid' && `pos`='IF' order by `fielding`"; $resultb = @mysql_query($sqlb) or die("couldn't execute query $sql.".mysql_error().mysql_error()); while($rowb = mysql_fetch_array($resultb)) { $count++; if($rowb{'index'}==$plid){ $if=$count; } } if($if==1){ $mypos="first"; $order++; } if($if==2){ $mypos="second"; $order++; } if($if==3){ $mypos="short"; $order++; } if($if==4){ $mypos="third"; $order++; } } if($pos=="OF"){ $count=0; $sqlb = "SELECT * FROM players WHERE `team`='$teamid' && `pos`='OF' order by `fielding`"; $resultb = @mysql_query($sqlb) or die("couldn't execute query $sql.".mysql_error().mysql_error()); while($rowb = mysql_fetch_array($resultb)) { $count++; if($rowb{'index'}==$plid){ $of=$count; } } if($of==1){ $mypos="left"; $order++; } if($of==2){ $mypos="center"; $order++; } if($of==3){ $mypos="right"; $order++; } } $sqlb = "SELECT * FROM pattributes_baseball WHERE `index`='$plid'"; $resultb = @mysql_query($sqlb) or die("couldn't execute query $sql.".mysql_error().mysql_error()); while($rowb = mysql_fetch_array($resultb)) { $phit=$rowb{'phit'}; $chit=$rowb{'chit'}; $plhit=$rowb{'plhit'}; $spd=$rowb{'spd'}; $glv=$rowb{'glv'}; $awr=$rowb{'awr'}; $arm=$rowb{'arm'}; $cnf=$rowb{'cnf'}; $clch=$rowb{'clch'}; $tlnt=$rowb{'tlnt'}; } $this->ratings[$mypos]=$plid; $this->ratings[$mypos][name]=$name; $this->ratings[$mypos][phit]=$phit; $this->ratings[$mypos][chit]=$chit; $this->ratings[$mypos][plhit]=$plhit; $this->ratings[$mypos][spd]=$spd; $this->ratings[$mypos][glv]=$glv; $this->ratings[$mypos][arm]=$arm; $this->ratings[$mypos][awr]=$awr; $this->ratings[$mypos][cnf]=$cnf; $this->ratings[$mypos][clch]=$clch; $this->ratings[$mypos][tlnt]=$tlnt; $this->ratings[batorder]=$plid; $this->ratings[batorder][$order][position]=$mypos; $this->ratings[batorder][$order][name]=$name; $this->ratings[batorder][$order][phit]=$phit; $this->ratings[batorder][$order][chit]=$chit; $this->ratings[batorder][$order][plhit]=$plhit; $this->ratings[batorder][$order][spd]=$spd; $this->ratings[batorder][$order][glv]=$glv; $this->ratings[batorder][$order][arm]=$arm; $this->ratings[batorder][$order][awr]=$awr; $this->ratings[batorder][$order][cnf]=$cnf; $this->ratings[batorder][$order][clch]=$clch; $this->ratings[batorder][$order][tlnt]=$tlnt; } $which=0; $sql = "SELECT * FROM players WHERE `team`='$teamid' && `pos`='P' order by `order`"; $result = @mysql_query($sql) or die("couldn't execute query $sql.".mysql_error().mysql_error()); while($row = mysql_fetch_array($result)) { $plid=$row{'index'}; $name=$row{'firstname'}. " " . $row{'lastname'}; $age=$row{'age'}; $pos=$row{'pos'}; $which++; if($gametime==$which){ $this->ratings[startpitch]=$plid; $this->ratings[startpitch][name]=$name; $this->ratings[startpitch][phit]=$phit; $this->ratings[startpitch][chit]=$chit; $this->ratings[startpitch][plhit]=$plhit; $this->ratings[startpitch][spd]=$spd; $this->ratings[startpitch][glv]=$glv; $this->ratings[startpitch][arm]=$arm; $this->ratings[startpitch][awr]=$awr; $this->ratings[startpitch][cnf]=$cnf; $this->ratings[startpitch][clch]=$clch; $this->ratings[startpitch][tlnt]=$tlnt; $this->ratings[batorder]=$plid; $this->ratings[batorder][9][name]=$name; $this->ratings[batorder][9][phit]=$phit; $this->ratings[batorder][9][chit]=$chit; $this->ratings[batorder][9][plhit]=$plhit; $this->ratings[batorder][9][spd]=$spd; $this->ratings[batorder][9][glv]=$glv; $this->ratings[batorder][9][arm]=$arm; $this->ratings[batorder][9][awr]=$awr; $this->ratings[batorder][9][cnf]=$cnf; $this->ratings[batorder][9][clch]=$clch; $this->ratings[batorder][9][tlnt]=$tlnt; } if($which==4){ $this->ratings[reliefpitch]=$plid; $this->ratings[reliefpitch][name]=$name; $this->ratings[reliefpitch][phit]=$phit; $this->ratings[reliefpitch][chit]=$chit; $this->ratings[reliefpitch][plhit]=$plhit; $this->ratings[reliefpitch][spd]=$spd; $this->ratings[reliefpitch][glv]=$glv; $this->ratings[reliefpitch][arm]=$arm; $this->ratings[reliefpitch][awr]=$awr; $this->ratings[reliefpitch][cnf]=$cnf; $this->ratings[reliefpitch][clch]=$clch; $this->ratings[reliefpitch][tlnt]=$tlnt; } if($which==5){ $this->ratings[closepitch]=$plid; $this->ratings[closepitch][name]=$name; $this->ratings[closepitch][phit]=$phit; $this->ratings[closepitch][chit]=$chit; $this->ratings[closepitch][plhit]=$plhit; $this->ratings[closepitch][spd]=$spd; $this->ratings[closepitch][glv]=$glv; $this->ratings[closepitch][arm]=$arm; $this->ratings[closepitch][awr]=$awr; $this->ratings[closepitch][cnf]=$cnf; $this->ratings[closepitch][clch]=$clch; $this->ratings[closepitch][tlnt]=$tlnt; } } } } ?>
  3. Hi- Im working on a baseball simulation where i store all player attributes in a multi dimension array. In the class i have an init function that pulls the data from the db and stores it as such: $this->ratings[$mypos]=$plid; $this->ratings[$mypos][name]=$name; $this->ratings[$mypos][phit]=$phit; $this->ratings[$mypos][chit]=$chit; $this->ratings[$mypos][plhit]=$plhit; $this->ratings[$mypos][spd]=$spd; $this->ratings[$mypos][glv]=$glv; $this->ratings[$mypos][arm]=$arm; $this->ratings[$mypos][awr]=$awr; $this->ratings[$mypos][cnf]=$cnf; $this->ratings[$mypos][clch]=$clch; $this->ratings[$mypos][tlnt]=$tlnt; But then when i print this array with print_r, i only get values for the first column: Array ( [catcher] => 98757 [batorder] => 18769 [] => 78769 [first] => 88759 [second] => 88760 [short] => 78761 [third] => 88762 [left] => 68765 [center] => 88766 [right] => 38767 [reliefpitch] => 78773 [closepitch] => 78774 ) Thoughts? Rob
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.