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

  • Home
  • SEARCH
  • 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 8969371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:34:55+00:00 2026-06-15T17:34:55+00:00

I have arrays within an array and I want to loop through each item

  • 0

I have arrays within an array and I want to loop through each item of the nested arrays and put them into different mysql columns. There is a limit of 3 entries per array, and I need $workexp_array_t to go into the work experience column, the $credentials_array_t items to go into the credentials column etc.

The problem I’m having is that using these nested foreach loops it just places the first letter of the entry into the column instead of the proper entry. How can I get each array items to go into their proper column? Do I really need to set up separate tables for each thing (ie. education experience, credentials, work experience, etc.)?

    $tutor_background = array($workexp_array_t, $credentials_array_t, $education_array_t, $extra_array_t);

foreach ($tutor_background as $entry) {
    foreach ($entry as $background) {
        $query = "INSERT INTO tutor_background (login_value, work_history, credentials, education_history, extra_skills) VALUES ('{$_SESSION['login_value']}', '{$background[0]}', '{$background[1]}', '{$background[2]}', '{$background[3]}')";
        $process_query = mysql_query($query);
    }
}
  • 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-15T17:34:55+00:00Added an answer on June 15, 2026 at 5:34 pm

    Going to take a guess here and say you only need one foreach.

    $tutor_background = array($workexp_array_t, $credentials_array_t, $education_array_t, $extra_array_t);
    
    foreach ($tutor_background as $entry) {
            $query = "INSERT INTO tutor_background (login_value, work_history, credentials, education_history, extra_skills) VALUES ('{$_SESSION['login_value']}', '{$entry[0]}', '{$entry[1]}', '{$entry[2]}', '{$entry[3]}')";
            $process_query = mysql_query($query);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have lots of details. I want to stack them within an array, can
I have a multidimensional array, and I would have multiple arrays within it. Some
Within the following code, $quiz_object->personalities contains an array of Personality objects. // Loop through
I have a set of categories I want to loop through, and set a
say i generated a set of random numbers and put them into an array,
I have an array of hashes that I want to turn into a table,
I have an array within an array. $a = array ( 0 => array
I have a struct which has several arrays within it. The arrays have type
Possible Duplicate: checking if pointer points within an array If I have an array
I have an array of values all well within the range 0 - 63,

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.