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 4575736
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:06:24+00:00 2026-05-21T20:06:24+00:00

Good morning, folks. I have a question here. I have three select. Brings first

  • 0

Good morning, folks.

I have a question here.

I have three select. Brings first product, quantity brings Second, Third brings value.
These are more select muntiplos as an array;

Ex:
$quantity = "1,2,3";
$value = "20.00,30.00,20.00";

Foreach had to do it.

    qty  value
$S ="1 * 20.00";
$S ="2 * 30.00";
$S ="1 * 20.00";

I am sending the page to have two to do the calculation.
More not getting to do two foreach with the data value and quantity.

Anyone know how I can sum this Vazer?

I would be very grateful.

EX:
  <select class="product" name=product[]" id="product[]">
             <option value="1"> Plan 1 </ option>
             <option value="2"> Plan 2 </ option>
  </ select>

  <select class="quantity" name=quantity[]" id="quantity[]">
             <option value="1"> 1 </ option>
             <option value="2"> 2 </ option>
  </ select>

  <select class="value" name=value[]" id="value[]">
             <option value="1"> 20:00 </ option>
             <option value="2"> 30.00 </ option>
  </ select>

Post
$quantity = $_POST["quantity"];
$value    = $_POST["value"];

$quantity = explode(',', $quantity_e);
$value    = explode(',', $value_e);

foreach ($quantity  as $q && $value as $v) { // ???

$v = $v * $q; // ????

}
  • 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-21T20:06:25+00:00Added an answer on May 21, 2026 at 8:06 pm

    Well, first of all, you’re not going to get any relevant information from your selects. Your 3 input arrays will look like this

    Array
    (
        [name] => (
            [0] => 1
            [1] => 2
            [2] => 1
        )
    
        [quantity] => (
            [0] => 1
            [1] => 1
            [2] => 2
        )
    
        [value] => (
            [0] => 2
            [1] => 2
            [2] => 2
        )
    )
    

    You are not passing anythign but 1’s and 2’s because the value attribute of all of your options is set to only 1’s and 2’s.

    You can either remove the value attribute all together and it will pass the text in options, or you could set value to the actual value you want to pass.

    Once you have the data in to format you originally specified, something like this would accomplish what I believe to be your goal.

    // make arrays from your comma delimited strings
    $quantity_array = explod(',',$quantity);
    $value_array    = explode(',',$quanity);
    
    // variable to store the total
    $total = 0;
    
    //iterate over them, summing them up
    foreach ( $quantity_array as $i => $qty )  // $i is the index
    {
        $item_total = $qty * $value_array[$i];  // the index should be the same for the values
        $total += $item_total;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning folks, I'm just that beginner in json, I have a formated data
Good morning all. I have an issue with a query. I want to select
Good morning, I have a question regarding default values and NULL values in Sybase
Good morning everybody. I have a question connected with controls and event handling. Lets
Good morning good folks! :) So here's what I'm trying to do. I've got
Good Morning All, I have an Objective C question that is coming from JavaScript.
Good morning SO, So I have a simple question I can't seem to find
Good morning, I have mysql queries where I would like to calculate percentage of
Good Morning. I have two tables, and one references the other. When I insert
Good morning. I've been having this issue for some days and have been lokking

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.