Jump to content

bwyant32

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by bwyant32

  1. I'm lost on that one, could you show me in the code that I have?
  2. Ok, I am running a baseball site and we have our player stats all in a table within a database. What I have is something like this, http://www.stlbleague.com/tm.php?tid=7... Now what I would like to do is have a row at the end of the pitching and hitting stats that says "Team Totals", here is a sample code that I have pulling the pitching stats: $id = $_GET['tid']; // get var from URL /* Get data. */ $sql = "SELECT player, pos, era, w, l, sv, hold, ip, bb, k, cg, sho, whip, k9 FROM 2012pitching LEFT JOIN roster ON 2012pitching.id=roster.id WHERE tid='$id'"; $result = mysql_query($sql); ?> <table width="962" border="0" cellpadding="2" cellspacing="1" class="stats2"> <tr class='theader'> <td align='center'>PLAYER</td> <td align='center'>POS</td> <td align='center'>ERA</td> <td align='center'>W</td> <td align='center'>L</td> <td align='center'>SV</td> <td align='center'>HOLD</td> <td align='center'>IP</td> <td align='center'>BB</td> <td align='center'>K</td> <td align='center'>CG</td> <td align='center'>SHO</td> <td align='center'>WHIP</td> <td align='center'>K/9</td> </tr> <?php $alternate = "2"; while ($row = mysql_fetch_array($result)) { $field1 = $row["player"]; $field2 = $row["pos"]; $field3 = $row["era"]; $field4 = $row["w"]; $field5 = $row["l"]; $field6 = $row["sv"]; $field7 = $row["hold"]; $field8 = $row["ip"]; $field9 = $row["bb"]; $field10 = $row["k"]; $field11 = $row["cg"]; $field12 = $row["sho"]; $field13 = $row["whip"]; $field14 = $row["k9"]; if ($alternate == "1") { $color = "#ffffff"; $alternate = "2"; } else { $color = "#E4E4E4"; $alternate = "1"; } echo "<tr bgcolor=$color><td>$field1</td><td align='center'>$field2</td><td align='center'>$field3</td><td align='center'>$field4</td><td align='center'>$field5</td><td align='center'>$field6</td><td align='center'>$field7</td><td align='center'>$field8</td><td align='center'>$field9</td><td align='center'>$field10</td><td align='center'>$field11</td><td align='center'>$field12</td><td align='center'>$field13</td><td align='center'>$field14</td></tr>"; } echo "</table>"; ?> So how could I use the Team ID associated with every player that it is pulling from to add a totals row? Thanks again in advance, Bobby
  3. That shouldn't be too hard to add. I do have the team Id in the players table, forgot to mention that. Now how would you go about creating the schedule and posting scores and stats through a web form for each and every game within the schedule?
  4. Or how much would someone charge to set this up? haha
  5. Ok I am into sports games for the PS3 and I help run a baseball league for MLB 12 The Show. We currently use a website for stat tracking called LeagueDaddy (http://www.leaguedaddy.com). I created this site (http://www.stlbleague.com) and I am pulling player stats from the LeagueDaddy site and exporting them into my databases. What I would like to do is set up a database structure so we can enter stats on our server and they will be updated in real time. Now I have figured out how to use the .php?id feature (as you can see here http://www.stlbleague.com/tm.php?tid=10). Now I have an idea for a database structure and here it is: Players Table - ID, Name, Photo, Age, other personal info Stats Table - Player ID, and then all the player's stats Teams Table - Team ID, and all the general Team Info Schedules Table - Game ID, Team IDs as the home and away team Those are the 4 major tables that I would need. I already have the players and teams tables set up properly. My question is, how could I get stats to store for each individual game so I could pull standings and many other things? Is this a reasonable idea given what I already have set up? What would you recommend that I look at as for a tutorial on how to do this? There is a site www.nnlcentral.com that already achieves what I want but for a different game; I welcome all tips and suggestions
  6. Ok I see the AS command and that looks like it would solve the issue. How would I incorporate that into my code? I'm drawing the blank there.
  7. That worked perfectly... this is what I am running into right now: http://www.stlbleague.com/test/tm.php?tid=1 (Team ID 1 is Arizona) Take the first game listed, Game ID #5 it shows Away - Arizona and Home - Arizona. When it should be Arizona v. St. Louis. So for some reason it is not matching up the actual game IDs. Here is my code: $id = $_GET['tid']; // get var from URL /* Get data. */ $sql = "SELECT * FROM schedule s LEFT JOIN teams h ON s.home=h.tid LEFT JOIN teams a ON s.away=a.tid WHERE away='$id' OR home='$id'" ; $result = mysql_query($sql); ?> <table width="962" border="0" cellpadding="2" cellspacing="1" class="stats"> <tr class='theader'> <td align='center'><a href='?sort=roster.player&order=<?php echo $order == 'DESC' ? 'ASC' : 'DESC' ?>'>ID</a></td> <td align='center'><a href='?sort=roster.player&order=<?php echo $order == 'DESC' ? 'ASC' : 'DESC' ?>'>Away</a></td> <td align='center'><a href='?sort=roster.tmabb&order=<?php echo $order == 'DESC' ? 'ASC' : 'DESC' ?>'>Home</a></td> </tr> <?php $alternate = "2"; while ($row = mysql_fetch_array($result)) { $field1 = $row["gid"]; $field2 = $row["full"]; $field3 = $row["full"]; if ($alternate == "1") { $color = "#ffffff"; $alternate = "2"; } else { $color = "#E4E4E4"; $alternate = "1"; } echo "<tr bgcolor=$color><td>$field1</td><td align='center'>$field2</td><td align='center'>$field2</td></tr>"; } echo "</table>"; ?>
  8. My fault, they are all in the same DB just different tables. My apologies.
  9. The thing is there are 30 teams and I will be creating 30 team schedules so thats why I wanted to pull by team ID
  10. I want to use whats in the schedule DB (the team IDs) and pull those IDs from the teams DB and give me the actual team names
  11. Ok I have a fairly straight forward question. I am designing a baseball website and I am trying to add in a schedule, here is what I have: Data Bases 1) Teams DB - Each team has a unique team ID, location, logo, and owner 2) Schedule DB - Each game has a unique game ID, and the schedule is set up like this: AWAY = Team ID, HOME = Team ID.... So I assume I am using the JOIN command to pull the schedule from both databases, any idea how the SQL command would look?
  12. I have looked all over the net on how to fix this... I am creating a baseball statistical website and I have 2 tables with identical columns (2012hitting and 2013hitting). I am trying to create a page where I can 1) group each year's statistics (which I have been able to do) and 2) have a row named "Career Totals". Each table has about 15 columns, various stats. How can I add the data from my 2012hitting table to my 2013hitting table into a Career Totals row for each player? This is what I'm trying now: /* CONNECTION VARIABLES */ $id = $_GET['id']; // get var from URL /* Get data. */ $sql = "SELECT * (sum(2012hitting.hr) +sum(2013hitting.hr)) as totalhr FROM 2012hitting, 2013hitting WHERE id='$id'"; $result = mysql_query($sql); ?> <?php $alternate = "2"; while ($row = mysql_fetch_array($result)) { $field1 = $row["season"]; $field2 = $row["team"]; $field3 = $row["games"]; $field4 = $row["ave"]; $field5 = $row["slg"]; $field6 = $row["r"]; $field7 = $row["h"]; $field8 = $row["rbi"]; $field9 = $row["bb"]; $field10 = $row["k"]; $field11 = $row["hr"]; $field12 = $row["dbl"]; $field13 = $row["tpl"]; $field14 = $row["sb"]; $field15 = $row["obp"]; $field16 = $row["ops"]; if ($alternate == "1") { $color = "#ffffff"; $alternate = "2"; } else { $color = "#E4E4E4"; $alternate = "1"; } echo "<tr bgcolor=$color><td align='center'>$field1</td><td align='center'>$field2</td><td align='center'>$field3</td><td align='center'>$field4</td><td align='center'>$field5</td><td align='center'>$field6</td><td align='center'>$field7</td><td align='center'>$field8</td><td align='center'>$field9</td><td align='center'>$field10</td><td align='center'>$field11</td><td align='center'>$field12</td><td align='center'>$field13</td><td align='center'>$field14</td><td align='center'>$field15</td><td align='center'>$field16</td></tr>"; } echo "</table>"; ?> Thank you 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.