Jump to content

[SOLVED] I need helping writing a particular piece of code please!


blurredvision

Recommended Posts

I'm trying to do something that I've never done before, and I cannot figure out the logic of how to get what I'm wanting.  So, hopefully one of you PHP masters can help me out with the code, and maybe make a couple of pointers so I can learn to do this.

 

I have a site and MySQL database that is keeping track of stats of games.  The stats of each individual game are stored into two different tables...one table for the hometeam stats, and one table for the awayteam stats.  I'm wanting to pull the stats from certain columns/fields from each table for a particular team.  Each team's games will obviously be in one table or the other, since they are sometimes the home team, sometimes the away team.

 

So let's say I'm wanting to pull a team's total offensive yards from each game it has played.  In the end, each team will ultimately have around 6 rows pulled from the hometeam table, and another 6 from the awayteam table.  Then, I'm wanting to add each game's total offensive yards to give a total of the team's offensive yards for the season.

 

Can anyone help me get started on this?  I'm assuming it will require some multi-dimensional arrays, something I've yet to mess with in PHP learnings.  Thanks for any help you guys can provide!!

The tables are so similar, just combine them into one table with a field for whether it was an away or home team for that specific game. It would be much more efficient and more simple to manage.

 

If you _must_ do it with separate tables, you won't have to use multidimensional arrays, you could just get the info from one table, put it in an array, and get the info from the other table and append it to the end of the same array. Then just get a sum of all the values in the array... but this is much less efficient than just combining the tables.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.