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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:08:05+00:00 2026-05-28T18:08:05+00:00

I have four arrays: $qtys = $_POST[‘qty’]; $colours = $_POST[‘colour’]; $sizes = $_POST[‘size’]; $names

  • 0

I have four arrays:

$qtys = $_POST['qty'];
$colours = $_POST['colour'];
$sizes = $_POST['size'];
$names = $_POST['name'];

I want these to go into a mysql table like so:

qty      | colour     | size     | name
-------------------------------------------
$qtys[0] | $colour[0] | $size[0] | $name[0]
$qtys[1] | $colour[1] | $size[1] | $name[1]

I’ve tried various things, including this:

foreach($qtys as $value) {
  $i = 0;
  mysql_query("INSERT INTO table (qty,colour,size,name) VALUES ('$qtys[$i]','$colours[$i]','$sizes[$i]','$names[$i]')");
  $i++;
} 

…but to no avail. Can anyone suggest a different INSERT statement that will get the data in the table? Do I need to iterate in the loop? I’m sure $qtys as $value is incorrect but have tried so many things with no luck.

  • 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-28T18:08:05+00:00Added an answer on May 28, 2026 at 6:08 pm

    Simply use for loop will be ok, AND REMEMBER ESCAPE USER INPUT.

    for($i =0, $count = count($qtys); $i < $count; $i++) {
      mysql_query("INSERT INTO table (qty,colour,size,name) VALUES ('$qtys[$i]','$colours[$i]','$sizes[$i]','$names[$i]')");
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four arrays: $text[], $ytext[], $titles[], $ytitles[] What I want to do is
I have four arrays of data (3072 bytes each.) I want to point to
How can I store arrays in single array? e.g. I have four different arrays,
I have a project that requires the following. Four arrays will be declared in
i have four radio buttons , and i want to set a text for
I have four arrays that are coming in from the client. Let's say that
I have four arrays as follows: toArray = [[NSMutableArray alloc] initWithObjects:@to 1,@to 2,@to 3,@to
lets say I have 2 arrays my @one = (one,two,three,four,five); my @two = (three,five);
I have four arrays, each with 3 (but can be more) elements. I am
I have four wheels which spin with the numbers 0-9: I want to be

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.