I am pulling records from a mysql db. Example Output: Team A= Our Team Team b = An opponent team Team A score = 7 Team B score = 8 Team A = Our Team Team b = Another Opponent Team A score = 3 Team B score = 1 What I need now is to add ONE more output, which is whether this is a "WIN" or a "LOSS". Should I add a field into the table that calc's this? If so, how? Please be specific. Or, should I use php to compare Team A score vs Team B score PER every record and then insert this new variable into the output. If so, how do I create a new variable value for every single output in the table? I know ultimately that this is a IF THEN type of calc, but can't quite figure out how specifically. Please be specific. Thanks in advance!
I would do 1 of 2 options. Either calculate the winner when you enter the scores into the db. This can be done via a trigger or can be done in the script that is used to update the scores assuming that they are not entered manually. Or, I would calculate when querying on the application level. The second is the logical way to do it, since all you need to do is compare the scores in the application when you're querying the db.
Though you say the 2nd way would be more logical, it seems that from a coding standpoint it would be "easier" to add the field, as I can they much easier to show records win/loss records etc. Either calculate the winner when you enter the scores into the db. This can be done via a trigger or can be done in the script that is used to update the scores "assuming that they are not entered manually." Can someone please go into more detail on this? Trigger or script. Also, not sure what is meant by scores "not entered manually". The scores / results table WILL be updated by users. When they do that, however, I want the "win/loss" field to then populate on the fly, just as an "auto number" field does. I do not want to have anyone "determine" themselves whether the score they entered is a win loss .