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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:43:05+00:00 2026-06-14T12:43:05+00:00

In java code i have this ArrayList<NameValuePair> al = new ArrayList<NameValuePair>(); for (int i

  • 0

In java code i have this

ArrayList<NameValuePair> al = new ArrayList<NameValuePair>();

for (int i = 0; i < alitems.size(); i++) {

    al.add(new BasicNameValuePair("items[]", alitems.get(i)));
    al.add(new BasicNameValuePair("qty[]", alnoof.get(i)));
    al.add(new BasicNameValuePair("price[]", alprice.get(i)));
}

Note: here alitems, alnoof, alprice are ArrayLists

php code

foreach (array_combine($_POST['items'], $_POST['qty']) as $val => $no) {

   $v = mysql_real_escape_string($val);
   $va = mysql_real_escape_string($no);
}

now i am able to get 2 array values of $v and $va but I am not able to get the price arraylist. How to do it?

suppose $_POST['items']={pencil,pen,watch}
        $_POST['qty']={2,3,4}
        $_POST['price']={20,30,40}

i need to insert values in database as :

pencil,2,20   pen,3,30   watch,4,40

Kindly help me on how to achieve this.

  • 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-06-14T12:43:07+00:00Added an answer on June 14, 2026 at 12:43 pm

    PHP also has for loop

    $_POST['items'] = ["pencil","pen","watch"];
    $_POST['qty'] = [2,3,4];
    $_POST['price'] = [20,30,40];
    
    for($i = 0; $i < count($_POST['items']); $i ++) {
        echo $_POST['items'][$i], " ", $_POST['qty'][$i], " ", $_POST['price'][$i], PHP_EOL;
    }
    

    Or

    foreach ( array_map(null, $_POST['items'], $_POST['qty'], $_POST['price']) as $var ) {
        list($item, $qty, $price) = $var;
        echo $item, " ", $qty, " ", $price, PHP_EOL;
    }
    

    Please not that [] is only supported in PHP >= 5.4 other whise you have to use array()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this java code: ArrayList<MessageMap> ids = getNewMail(UserID, type, maxIdMessage); Message[] message =
Context I have this piece of Java Code btn.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent
I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int
I have this code: package com.problemio; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList;
i have this code: static ArrayList<Integer> output_list = new ArrayList<Integer>(); static ArrayList<Integer> pair_list =
I have this code package com.cerbertek; import java.util.ArrayList; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory;
i have this code: public class Test{ arrayList<String> list = new ArrayList<String>(); String[][] temp_list;
I have this code snippet import java.util.ArrayList; import java.util.List; public class AssertTest { public
I have this Java code, and I want to do the same thing in
I have a cross-language problem regarding md5 :). I have this code in Java:

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.