View Full Version : High, Avg. Low... Help with Math

04-06-2004, 09:25 AM
Hey, first off, dont bash me for being a newbie with php, Im trying to learn it as efficiently as I can :);)

Anyway, Im kinda at a loss as to where to start with the equations, I guess you can call them that.

What I am trying to do, is devise a system that has 3 values. A high, an Average, and a Low. Then, if you submit another value to it, it will automatically change the average and if the submited value is higher it will change the previous high to the submited high, and the same system with the low. Does that make sence?

It doesnt seem that complicated.. just I dont know enough php to get this set up. I was just using HTML tables and doing the math myself, but now Id like to have a more eased system of doing things. Anyone feel like directing me on a path to move on?

By the way, this has nothing to do with homework, its actually to work with prices for a game Im playing, and to find a good high/low price to buy/sell... just to get that outta the way ;).

Thanks for any help you guys give me, Im extremely sure that it will be very valuable and helpfull.

04-06-2004, 09:42 AM
Anyone feel like directing me on a path to move on? Sure. Best use an array. Take a look here
and look into the

04-06-2004, 10:19 AM
Ugh... that seemed to make it worse than I thought it would be... Ive never heard of arrays till you gave me that link..:(

I said I was newb at PHP, so I guess I should expect to run into stuff like that. Gonna have to do my homework now..

04-06-2004, 11:06 AM
I see. But you'll need to learn working with arrays anyway. There's nothing complicated to it. You'll also need to store the array somewhere (in a file that you then include. and that you edit when you submit a new value.

Personally, i'd use a database for this sort of things, but that is mainly because i always make db-driven websites. For this feature alone, i wouldn't recommend setting up a db, but if you will be using a db for some oher stuff in your site, then it would be best to use a db.
You can then use the max(), min(), avg() SQLfunctions to get your 3 values.

04-06-2004, 11:25 AM
Already your about 5 steps ahead of me. I wanted to know how to get started... I dont know where to begin with the coding. :confused: No idea. You stuck me with Arrays. I dont know what to do with arrays. Todays the first Ive looked at them and found out about them.... :o

Meh... is it really this complicated just to get a High Avg and Low value and then have it update after another value is placed in???

Sorry if I seem a bit... irritated... it is late here, and Im intending to sleep very shortly...

04-06-2004, 11:35 AM
If you're starting from the ground up, then i suppose every approach will be difficult (because you need to have an editable collection, that needs to be permanently stored somewhere + that needs to be ordered and processes at runtime).
But you need to jump in and start messing around. If you run into problems, then just post your code + accurate problemdescription here, and we'll help you solve it.

Here are some tutorials about arrays

04-06-2004, 04:56 PM
I found this tutorial helpful