Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    High, Avg. Low... Help with Math

    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.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anyone feel like directing me on a path to move on?
    Sure. Best use an array. Take a look here
    http://www.php.net/manual/en/ref.array.php
    and look into the
    sort()
    array_sum()
    count()
    functions.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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..

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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. 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....

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

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    http://www.hotscripts.com/cgi-bin/se...arrays&catid=2
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #7
    New Coder
    Join Date
    Apr 2004
    Location
    NC
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •