Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 557017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:58:52+00:00 2026-05-13T11:58:52+00:00

Here’s one that’s got me stumped. Working in PHP5. I am building a store

  • 0

Here’s one that’s got me stumped. Working in PHP5.

I am building a store application for a client that makes use of a web service from a larger agency as he is a broker. This web service requires that items for purchase by end users be of a certain quantity or else the order will be considered ineligible for purchase.

I must make dropdown option boxes that contain only eligible quantity numbers. Their rules are as follows:

If a quantity greater than 12 is available, then allow any quantity EXCEPT that which would leave only one item remaining

If a quantity of less than 12 is available and said quantity is even, then allow only even pairs for purchase

If a quantity of of less than 12 is available and said quantity is odd, then allow any quantity except that which would leave only one item remaining.

I’m a bit confused as to how my conditionals to determine dropdown content should be structured to accommodate this. How could I know in advance, via conditionals, whether the final quantity vs the user’s requested quantity would leave just one for purchase and thereby deny it?

I can’t imagine why the service issuer did not make it so an array of eligible quantities was returned rather than a hard number. Please also note there are two other rules that I’ve already manage to mete out.

Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:58:53+00:00Added an answer on May 13, 2026 at 11:58 am
    if($avail>12 || $avail%2) {
      $step = 1;  // all qtys for large avail or odd avail
    } else {
      $step = 2;  // even qtys for small even avail
    }
    $options = array();
    for($i = $avail-($step==1); $i > 0; $i-=$step) { // skip qty=avail for step=1
      $options[] = $i;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
here a a piece of code that is supposed to loop over and over
Here is shown how to use styles in CamelCase, but how to use styles
Here I had a problem that I am adding contact from the address book
Here's my code $string = preg_replace(/rad\:([0-9]+)px\;\s+\/\*\sALT\[(.+)\*\/|rad\:([0-9]+)px\;/,($2?$2:$1),$string); Basically, in the regex I've got a pipe
Here's a problem I ran into recently. I have attributes strings of the form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.