warning: patience required / need to build simple standings
Posted: Tue Feb 20, 2007 10:13 pm
Hi! I read somewhere it's ok to post really newbie questions (viewtopic.php?t=43152&), so I'll try my best:
I need to build a simple standings page in php for a small sports site. It only has to deal with 6 teams and 4 variables: name, games played, games lost and points. No need to say that I'm less than newbie with php and I've wasted a bunch of time trying to figure it out on my own, and that's the only thing I don't have right now. That's why I'm only using php, don't want to make it even more complicated with a db or something, at least for a little while.
What I've done so far is that I've created 6 functions, one for each team, with different variables that do the math just fine, the problem is that when I have to print them in the page, it always returns the values in the same order (team a first, team b second.....), and I need them to be returned in descending order, depending on who has more points...
I've been trying with different functions (if, while, etc.) but it seems to me than in order to make those work, I would have to do all the scenarios, which means repeating the code for each probability. That is 6*5*4*3*2*1. That seems even stupid to me! I'm sure there has to be a better way.
I don't know if arrays would help. Not knowing much, it's almost impossible for me to understand what exaclty they do. Is that the way to go?
Heeeelp!
Thanks for your time!
I need to build a simple standings page in php for a small sports site. It only has to deal with 6 teams and 4 variables: name, games played, games lost and points. No need to say that I'm less than newbie with php and I've wasted a bunch of time trying to figure it out on my own, and that's the only thing I don't have right now. That's why I'm only using php, don't want to make it even more complicated with a db or something, at least for a little while.
What I've done so far is that I've created 6 functions, one for each team, with different variables that do the math just fine, the problem is that when I have to print them in the page, it always returns the values in the same order (team a first, team b second.....), and I need them to be returned in descending order, depending on who has more points...
I've been trying with different functions (if, while, etc.) but it seems to me than in order to make those work, I would have to do all the scenarios, which means repeating the code for each probability. That is 6*5*4*3*2*1. That seems even stupid to me! I'm sure there has to be a better way.
I don't know if arrays would help. Not knowing much, it's almost impossible for me to understand what exaclty they do. Is that the way to go?
Heeeelp!
Thanks for your time!