Results 1 to 1 of 1

Thread: How to combine three parts of code

  1. #1
    Join Date
    Dec 2009
    Posts
    48
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default How to combine three parts of code

    Hello,

    I am looking for a little help on how to combine three parts of code.

    Here's part one:

    PHP Code:
    $base_m=5;
    {
    $item['price'] = round ((($item['price']+5) *1.85),0); $item['pricefinal'] = $base_m*(ceil(($item['price'])/$base_m));} 
    So if the price from the db is 20, the above line will create: (20 + 5) * 1,85. Which makes the final price 46.25. Also, everything is rounded up by 5.

    Here's part two:

    PHP Code:
        if (($item['price'] > "11") && ($item['pricefinal'] < "100")) { ?> &euro;&nbsp;&nbsp;&nbsp;&nbsp; <?php echo $item['pricefinal']; ?>,- <?php }
         elseif ((
    $item['price'] > "11") && ($item['pricefinal'] < "1000")) { ?> &euro;&nbsp;&nbsp; <?php echo $item['pricefinal']; ?>,- <?php }
          elseif ((
    $item['price'] > "11") && ($item['pricefinal'] >= "1000")) { ?> &euro; <?php echo $item['pricefinal']; ?>,- <?php }
    Meaning prices must be bigger than 11 before being showed and the smaller or bigger than 100 and 1000 parts are just to align the euro sign and the prices all nicely underneath each other.

    Now, the two above parts of code are working well together already. I´m just showing these to point out the many things that need to be done with the prices, making it not easy (at least for me) to add the following code...

    Here´s part three:

    PHP Code:
    print min(1007010150);
    // returns --> 50
     
    OR

    $array = array(10070124202);
    print 
    min($array);
    // returns --> 2 
    Basically, I have three different prices and only the lowest one must be displayed (with the added math function and be aligned, also must be higher than 11).

    So let's say the prices are 10, 20 and 25.
    I'd like the script to use the price of 20. Meaning the value shown will be 50 (after being rounded up).

    I hope you understand all that I've said here, if not, lemme know and I'll explain more. I have no idea how to add in the 'find lowest' part into the script as it is.... I know the code might look messy, I'm sorry for that, but I don't know another way to do this...

    Thank you in advance!!
    Last edited by Bar2aYunie; 12-05-2010 at 06:29 PM.

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
  •