Jump to content

phpbeginner

Members
  • Posts

    214
  • Joined

  • Last visited

Everything posted by phpbeginner

  1. I thought I had this problem corrected awhile ago ( with the fine help of members in here ) but I have one problem with the script below. What I have is a hockey database in which I am trying to pull 1 team record from. This team can either be listed as Team 1 or Team 2 depending on wether it is a home or away game. The problem I am having is it this code below is just retrieving info from the team 1 side and creating the record. The scores are all entered correctly into my DB but rather than displaying a record of 13 Wins 11 Losses 26 Points, it is displaying 9 Wins 15 Losses 18 Points. Any Ideas ? Thanks In Advance ! [sub]<?php $sql_standings = "SELECT * FROM schedule_scores WHERE        (team1 = '0002' OR team2 = '0002') AND       season = '000000000001'";   $result_standings = mysql_query("$sql_standings");   $total_standings = mysql_numrows($result_standings);   $standings_array = "";   $standings_array = array();   $i = 0;   while ($i < $total_standings) {       $team1 = mysql_result($result_standings,$i,"team1");       $team2 = mysql_result($result_standings,$i,"team2");       $t1_score = mysql_result($result_standings,$i,"team1_score");       $t2_score = mysql_result($result_standings,$i,"team2_score");       $gm_ot = mysql_result($result_standings,$i,"ot_game");       $team1_id = 0002;       $team2_id = 0002;   if($tid == 0002)   {       if($t1_score > $t2_score)       {                   $standings_array["w"] = $standings_array["w"] + 1;         $standings_array["pts"] = $standings_array["pts"] + 2;         $standings_array["l"] = $standings_array["l"] + 0;         } {         if($t1_score > $t2_score AND $gm_ot == 1) {             $standings_array["pts"] = $standings_array["pts"] + 1;             $standings_array["otl"] = $standings_array["otl"] + 1;                      $standings_array["l"] = $standings_array["l"] + 0;                   } else if($t1_score < $t2_score)             $standings_array["l"] = $standings_array["l"] + 1;               }   } else {       if($t2_score > $t1_score)       {                   $standings_array["w"] = $standings_array["w"] + 1;         $standings_array["pts"] = $standings_array["pts"] + 2;         $standings_array["l"] = $standings_array["l"] + 0;           }   {         if($t1_score < $t2_score AND $gm_ot == 1) {             $standings_array["pts"] = $standings_array["pts"] + 1;             $standings_array["otl"] = $standings_array["otl"] + 1;             $standings_array["l"] = $standings_array["l"] + 0;   }   else if($t2_score < $t1_score)             $standings_array["l"] = $standings_array["l"] + 1;                                        }   }   $i++; }$testteam_array = array();  {         echo  $standings .= "                 <tr bgcolor=\"#FFFFFF\" align=\"left\" valign=\"middle\">                                                   <td class=\"table_text\" align=center>".$standings_array["w"]."</td>                   <td class=\"table_text\" align=center>".$standings_array["l"]."</td><td class=\"table_text\" align=center>".$standings_array["otl"]."</td>                                                         <td class=\"table_text\" bgcolor=\"#efefef\" align=center>".$standings_array["pts"]."</td></tr>";       //ADD TEAMS WITH STANDINGS TO TESTTEAM ARRAY         $t_w_stats = $value["id"];               array_push($testteam_array, "$t_w_stats");   }   ?>[/sub]
  2. Okay Thanks for the time and help.....I finally got it
  3. cool. thanks for that tip also. Its not a math problem, my output is fine other than its displaying 2 seperate outputs. Its tracking everything fine and w, l, pts are all correct its just doing this as an example: TeamName GP-3 W-1 L-2 Pts-2 TeamName GP-1 W-0 L-1 Pts-0 When I am looking for Team GP-4 W-1 L-3 Pts-2 I hope that helps.
  4. ahhh, I see, thanks for that I appreciate it. What about point 1 ?
  5. 1) In my table where I am getting this data, there is a team 1 score and then there is a team 2 score depending on home or away games were played. This code generates the output as if team id 0002 was 2 seperate teams. It comes out as Team 1 is 0 wins 3 losses, etc. then displays underneath Team 2 is 1 win 0 losses, when team 1 and team 2 are actually the same team. I am trying to combine into 1 stat. 2)The giant id/else blocks are different in the sense that the first is if($t1_score > $t2_score) and the second is  if($t2_score > $t1_score)
  6. I am having problems displaying one team record from a DB. The website is for one team but keeps track of home away games. When its an away game the team is then put under team 2. What I am doing is getting the record from scores for the team which could either be under team 1 or team 2 from the DB but its showing up as 2 seperate teams rather than totalling to one team. Here is what I have.. ...... [sup]<?php $sql_standings = "SELECT * FROM schedule_scores WHERE "       ."(team1 = '0002' OR team2 = '0002') AND "       ."season = '000000000009'";   $result_standings = mysql_query("$sql_standings");   $total_standings = mysql_numrows($result_standings);   $standings_array = "";   $standings_array = array();   $i = 0;   while ($i < $total_standings) {       $team1 = mysql_result($result_standings,$i,"team1");       $team2 = mysql_result($result_standings,$i,"team2");       $t1_score = mysql_result($result_standings,$i,"team1_score");       $t2_score = mysql_result($result_standings,$i,"team2_score");       $gm_ot = mysql_result($result_standings,$i,"ot_game");       $team1_id = 0002;       $team2_id = 0002;   if($tid == 0002)   {       if($t1_score > $t2_score)       {         $standings_array[$team1]["w"] = $standings_array[$team1]["w"] + 1;         $standings_array[$team1]["pts"] = $standings_array[$team1]["pts"] + 2;         $standings_array[$team1]["l"] = $standings_array[$team1]["l"] + 0;       }elseif($t1_score < $t2_score){         if($gm_ot == 1) {             $standings_array[$team1]["otl"] = $standings_array[$team1]["otl"] + 1;             $standings_array[$team1]["pts"] = $standings_array[$team1]["pts"] + 1;             $standings_array[$team1]["l"] = $standings_array[$team1]["l"] + 0;         }else{             $standings_array[$team1]["l"] = $standings_array[$team1]["l"] + 1;         }       }   } else {       if($t2_score > $t1_score)       {         $standings_array[$team1]["w"] = $standings_array[$team1]["w"] + 1;         $standings_array[$team1]["pts"] = $standings_array[$team1]["pts"] + 2;         $standings_array[$team1]["l"] = $standings_array[$team1]["l"] + 0;               }elseif($t2_score < $t1_score){         if($gm_ot == 1) {             $standings_array[$team1]["otl"] = $standings_array[$team1]["otl"] + 1;             $standings_array[$team1]["pts"] = $standings_array[$team1]["pts"] + 1;             $standings_array[$team1]["l"] = $standings_array[$team1]["l"] + 0;         }else{             $standings_array[$team1]["l"] = $standings_array[$team1]["l"] + 1;         }       }   }   $i++; } $testteam_array = array(); while (list ($key, $value) = each ($standings_array)) {       $standings .=               print "<tr bgcolor=\"#FFFFFF\" align=\"left\" valign=\"middle\">                 <td class=\"table_text\" align=center>".$value["gp"]."</td>                 <td class=\"table_text\" align=center>".$value["w"]."</td>                 <td class=\"table_text\" align=center>".$value["l"]."</td>                 <td class=\"table_text\" align=center>".$value["d"]."</td>                 <td class=\"table_text\" align=center>".$value["otl"]."</td>                 <td class=\"table_text\" bgcolor=\"#efefef\" align=center>".$value["pts"]."</td>                 <td class=\"table_text\" align=center>".$value["gf"]."</td>                 <td class=\"table_text\" align=center>".$value["ga"]."</td>"; //ADD TEAMS WITH STANDINGS TO TESTTEAM ARRAY $t_w_stats = $value["id"];         array_push($testteam_array, "$t_w_stats"); } print "  </td>   </tr> </table>" ?>[/sup]
  7. Thanks so much.....works beautiful.
  8. thanks, thought there may have been something I could do here in this snippet.... $p_array[$playerid][gaa] = ROUND('1.00' * ($p_array[$playerid][goalsa]) * (60/$p_array[$playerid][minutes]), 2); like this.... $p_array[$playerid][gaa] = ROUND('1.00' * ($p_array[$playerid][goalsa]) * (60/$p_array[$playerid][minutes]), 2,'.',' ');
  9. Hello, I have a quick question. I am doing a stats program for a hockey team and the question I have is that I have the decimals correct for the goaltenders goals against average and save % as I wish, except for the fact that if its an even # like 2 it will display 2 rather than 2.00. Works fine when the #'s are not even rounding off to 2 and 3 decimals respectively. Here is the code for the GAA.... $p_array[$playerid][gaa] = ROUND('1.00' * ($p_array[$playerid][goalsa]) * (60/$p_array[$playerid][minutes]), 2); Any help would be appreciated......thanks in advance !
  10. [!--quoteo(post=367449:date=Apr 22 2006, 09:18 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 22 2006, 09:18 AM) [snapback]367449[/snapback][/div][div class=\'quotemain\'][!--quotec--] If you want an image to display tnen placed the path of the image in side the " marks like so: [code]$profile[$key]["image"] = "path/to/image/here.gif";[/code] [/quote] Thanks, I did do that originally, thats why I thought something I was missing. All I get is the path text displaying in the area now. [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--] /profile/uploads/nophoto.jpg [!--colorc--][/span][!--/colorc--]
  11. I am trying to link to a "No Photo Available" image if no file is uploaded ( rather than having a blank space ). I just can't seem to get it to work. The code is [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]} else { $profile[$key]["image"] = ""; }[!--colorc--][/span][!--/colorc--] Right now this just shows a blank area with no borders and I would like to link to an image file which I have made. Thanks in Advance
  12. Hello, first of all this is a great site and I have been frequenting it alot lately as I have been struggling through with MySQL and PHP a bit as a beginner and I find this place very helpful. I have bascially built a database with a few tables and seem to be having some trouble with one in particular. Its for a hockey team and what I have in this table is a hockey game details. I show a few fields from the table in which they can link to the complete game details for that particular game. I have tried to do this and either get all the game detail results or none. I currently have none with the code below. I have tried linking to the complete details page by either using the gamenumber ( autoincrement primary key ) and have also tried game "date". Here is the code below and please do not laugh to loud as I am a beginner. This is my game details page in which I have either gotten all records or none..... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]mysql_connect($dbserver, $dbuser, $dbpass) or die ("UNABLE TO CONNECT TO DATABASE"); mysql_select_db($dbname) or die ("UNABLE TO SELECT DATABASE"); echo "<table width=500 bgcolor=000000 cellpadding=2 border=1><tr><td width=200 height=20 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><b>Teams</b></u></td><td width=50 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><b>1st </b></u></td><td width=50 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><b>2 nd</b></u></td><td width=50 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><b>3 rd</b></u></td><td width=50 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><b>Total</b></div></u></td><td width=50 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><b>SOG</b></u></td>"; echo "</td></tr></table>"; $sql = 'SELECT gamenumber, versus, sea_score_1st, sea_score_2nd, sea_score_3rd, sea_score_total, vs_score_1st, vs_score_2nd, vs_score_3rd, vs_score_total, sea_shots, vs_shots, period1_scores, period2_scores, period3_scores, period1_penalties, period2_penalties, period3_penalties FROM `game` WHERE gamenumber ="$gamenumber"';; $result = mysql_query($sql); if ($myrow = mysql_fetch_array($result)) { do { $date=$myrow["date"]; $gamenumber=$myrow["gamenumber"]; $versus=$myrow["versus"]; $sea_score_1st=$myrow["sea_score_1st"]; $sea_score_2nd=$myrow["sea_score_2nd"]; $sea_score_3rd=$myrow["sea_score_3rd"]; $sea_score_total=$myrow["sea_score_total"]; $vs_score_1st=$myrow["vs_score_1st"]; $vs_score_2nd=$myrow["vs_score_2nd"]; $vs_score_3rd=$myrow["vs_score_3rd"]; $vs_score_total=$myrow["vs_score_total"]; $sea_shots=$myrow["sea_shots"]; $vs_shots=$myrow["vs_shots"]; $period1_scores=$myrow["period1_scores"]; $period2_scores=$myrow["period2_scores"]; $period3_scores=$myrow["period3_scores"]; $period1_penalties=$myrow["period1_penalties"]; $period2_penalties=$myrow["period2_penalties"]; $period3_penalties=$myrow["period3_penalties"]; echo "<table width=500 bgcolor=#232323 cellpadding=2 border=1><tr><td width=200 height=20 bgcolor=#333333 valign=top>"; echo "<font face=Tahoma size=2 color=ffffff><b>Seahawks</b></font><hr>"; echo "<font face=Tahoma size=2 color=ffffff><b>$versus</b></font></td>"; echo "<td width=50 height=20 bgcolor=#333333>"; echo "<font face=Tahoma size=2 color=ffffff>$sea_score_1st<hr>"; echo "<font face=Tahoma size=2 color=ffffff>$vs_score_1st</td>"; echo "<td width=50 height=20 bgcolor=#333333>"; echo "<font face=Tahoma size=2 color=ffffff>$sea_score_2nd<hr>"; echo "<font face=Tahoma size=2 color=ffffff>$vs_score_2nd</td>"; echo "<td width=50 height=20 bgcolor=#333333>"; echo "<font face=Tahoma size=2 color=ffffff>$sea_score_3rd<hr>"; echo "<font face=Tahoma size=2 color=ffffff>$vs_score_3rd</td>"; echo "<td width=50 height=20 bgcolor=#333333>"; echo "<font face=Tahoma size=2 color=ffffff>$sea_score_total<hr>"; echo "<font face=Tahoma size=2 color=ffffff>$vs_score_total</td>"; echo "<td width=50 height=20 bgcolor=#333333>"; echo "<font face=Tahoma size=2 color=ffffff>$sea_shots<hr>"; echo "<font face=Tahoma size=2 color=ffffff>$vs_shots</td>"; echo "</td></tr></table>"; echo "<table width=750 bgcolor=#232323 cellpadding=2 border=1>"; echo "<tr><td bgcolor=000000><font face=Tahoma size=2 color=ff0000><b><center><u>1st Period Scoring</u></center></b></font></td></tr><br>"; echo "<tr><td bgcolor=333333><font face=Tahoma size=2 color=ffffff>$period1_scores</font></td></tr>"; echo "<tr><td bgcolor=000000><font face=Tahoma size=2 color=ff0000><b><center><u>2nd Period Scoring</u></center></b></font>"; echo "<tr><td bgcolor=333333><font face=Tahoma size=2 color=ffffff>$period2_scores</font>"; echo "<tr><td bgcolor=000000><font face=Tahoma size=2 color=ff0000><b><center><u>3rdPeriod Scoring</u></center></b></font>"; echo "<tr><td bgcolor=333333><font face=Tahoma size=2 color=ffffff>$period3_scores</font>"; echo "<tr><td bgcolor=000000><font face=Tahoma size=2 color=ff0000><b><center><u>1st Period Penalties</u></center></b></font>"; echo "<tr><td bgcolor=333333><font face=Tahoma size=2 color=ffffff>$period1_penalties</font>"; echo "<tr><td bgcolor=000000><font face=Tahoma size=2 color=ff0000><b><center><u>2nd Period Penalties</u></center></b></font>"; echo "<tr><td bgcolor=333333><font face=Tahoma size=2 color=ffffff>$period2_penalties</font>"; echo "<tr><td bgcolor=000000><font face=Tahoma size=2 color=ff0000><b><center><u>3rd Period Penalties</u></center></b></font>"; echo "<tr><td bgcolor=333333><font face=Tahoma size=2 color=ffffff>$period3_penalties</font>"; echo "</td></tr></table><p>"; } while ($myrow = mysql_fetch_array($result)); } ?> Here is the basic one with the link in which I am trying to get to the specific record of the game.... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]mysql_connect($dbserver, $dbuser, $dbpass) or die ("UNABLE TO CONNECT TO DATABASE"); mysql_select_db($dbname) or die ("UNABLE TO SELECT DATABASE"); echo "<table width=500 bgcolor=000000 cellpadding=2 border=1><tr><td width=100 height=20 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><div align=center><b>DATE</b></div></u></td><td width=300 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><div align=center><b>GAME SCORE</b></div></u></td><td width=100 bgcolor=#000000><font face=Tahoma size=2 color=#ff0000><u><div align=center><b>DETAILS</b></div></u>"; echo "</td></tr></table>"; $sql = 'SELECT DISTINCT `date`,`versus`,`sea_score_total`,`vs_score_total`, `gamenumber` FROM `game` ';; $result = mysql_query($sql); if ($myrow = mysql_fetch_array($result)) { do { $date=$myrow["date"]; $versus=$myrow["versus"]; $sea_score_total=$myrow["sea_score_total"]; $vs_score_total=$myrow["vs_score_total"]; $gamenumber=$myrow["gamenumber"]; echo "<table width=500 bgcolor=#232323 cellpadding=2 border=1><tr><td width=100 height=20 bgcolor=#333333 valign=top>"; echo "<font face=Tahoma size=2 align=center>$date</a></font></td>"; echo "<td height=20 bgcolor=#333333 valign=top>"; echo "<font face=Tahoma size=2> <b><font color=ff00000>Seahawks</b></font> - $sea_score_total"; echo " <font color=ff0000><b>$versus</b></font> - $vs_score_total</td>"; echo "<td bgcolor=333333><font color=FF0000><b><a href=viewgame.php?gamenumber=$gamenumber> Details </a></b></font>"; echo "</td></tr></table>"; } while ($myrow = mysql_fetch_array($result)); } ?> I did get this far and everything so far has been working good for me. Thanks in advance.
×
×
  • 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.