SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Which value is nearer than these?

    I have a value that defines the quantity of bottles of wine each box has. For eg: Each box has 50.

    My customer sent me a quantity of bottles that he wants to buy, that may accord or not to the exact number of bottles per box. I can't sell an incomplete box, so all the quantity's I can sell are: 50 and it's multipliers, such as 100, 150, 200, 250.

    In case the bottles of the customer doesn't fix an exact-box-quantity, I need a script that chooses from the nearer higher value. For example:

    If he wants to buy 60, he has to take 100. If he wants to have 430, he needs to take 450.

    Thanx!

  2. #2
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    $qty 
    ceil($howmanyuserwants $howmanyperbox) * $howmanyperbox;

    // eg. 60/50 = 2 * 50 = 100. 


Bookmarks

Posting Permissions

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