How do you make an automatic price averager? (Read)
I'm having a bit of an issue, in the real world there's an economy of goods and prices, an ever changing one, The average price on a jar of honey may be $3 today but in 4 days it could be $3.25, everything changes constantly, is there a way where i could do something like this with tables? I want to be able to let users put in what the think a good price for the item would be and it takes the other prices and averages them automatically and displays the price. For example,
I have listed an apple, the starting value of the apple is $3
User 1 thinks the apple is worth around $4
($4 + $3)x .5 = $3.50 (Average cost of an Apple)
This price is now displayed to the community, that the average price of an apple is $3.50, now say another user comes around,
User 2 thinks the apple is somewhere around $2.75
($4 + $3 + $2.75) x .5 = $4.87
Now, the average price of an apple that would be displayed to the community is $4.87, is there something like this that i could use on my website? Whether it is open source or not doesn't matter, something that will check the MySQL databases for previous data and average out the information/prices/data to give an end average price between the submitted prices?
I've been having quite some trouble with this issue, i'm looking to create a price guide for online items in a gaming community, is there an easy way to do this?
Because you don't know how many items there will be, or how many values
are placed on those items, I would think you would have one table in your MySQL
database that stores all of them. Each time someone gives a value to an apple,
it would insert a new line. There could be 50 rows for apples, 30 rows for oranges,
and 100 rows for bananas. You query for a particular item, you know how many
rows it found, and you SUM the values ... now you can determine the average.
If you also add a column with a timestamp, you could query the table for an item
within a certain amount of time (days, months, years). You may want to know the
average price for the apples only during the past month.
Thank you both very much, hopefully with your replies and some other information on coding this, i'll be able to get it done with-in the next couple days. Your information was very useful. Thanked, -Skill3d