SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot asterikx's Avatar
    Join Date
    May 2002
    Location
    Montana
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Using less than, greater than to perform a calculation

    I'm selling greeting cards. The price is based on how many cards the user orders. The calculations that I'm using currently do not calculate the correct price. Here's how it works now:

    PHP Code:
    $price1 "1.00";
    $price2 "1.25";

    if (
    $quantity 25) {
         echo(
    "The minimum order is 25 cards.");
    }

    if (
    $quantity 75) {
         
    $price $price1*($quantity);
    }

    if (
    $quantity 100) {
         
    $price $price2*($quantity); 
    So if the user enters an quantity of 70 cards, both if statements are true. How do I code the statement: "If quantity is less than 75 and greater than 24 then the price will equal X"?

    -- Coffee and SitePoint.com are the keys to a great site!


    Thanks!

    -- asterikx
    Manifest Creative is located in beautiful Bozeman, Montana.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    PHP Code:
    if ($quantity 24 && $quantity 75) {
         
    $price $price1*($quantity);


  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And i think this will also work with the word "AND"
    PHP Code:
    if ($quantity 24 AND $quantity 75) {
         
    $price $price1*($quantity);



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
  •