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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:12:56+00:00 2026-06-08T12:12:56+00:00

Consider the following : I have several arrays (let’s say 2), that I get

  • 0

Consider the following :
I have several arrays (let’s say 2), that I get with post, like that :

$_POST['date-pack'] :
$date_pack array {
[0] ==> "Juillet 2012"
[1] ==> "Avril 2012"
...

And with this array, I have another one with the id’s in the same order as the dates :

$_POST['id_pack'] :
$id_pack array {
[0] ==> "6"
[1] ==> "8"
...

The thing is, I want to update a table, like that :

"UPDATE my_table 
SET date_service = *the_first_date_in_array*
WHERE id_service = *the first_id_in_array*"

and then do the same thing for all the elements in my arrays (they’ll have the same number of elements).

I don’t know if it’s possible to use “foreach” with several arrays and put my query into the loop … ?

Thanks in advance for your help !

  • 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-08T12:12:57+00:00Added an answer on June 8, 2026 at 12:12 pm

    Why not use something like:

    if(is_array($_POST['date_pack'])
    {
        for($i=0;$i<count($_POST['date_pack'];$i++)
        {
        $sql='
        UPDATE my_table 
        SET date_service = '.$_POST['date_pack'][$i].'
        WHERE 
            id_service = '.$_POST['id_pack'][$i].'
            -- and your other conditions....
        ';
        }
    }
    else
    {
        $sql='
        UPDATE my_table 
        SET date_service = '.$_POST['date_pack'].'
        WHERE 
            id_service = '.$_POST['id_pack'].'
            -- and your other conditions....
        ';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider following scenario: I have RESTful URL /articles that returns list of articles user
Consider the following scenario We have a simple database that involves two entities: user
Let's consider following, simplified example: We have 2 tabs withing <rich:tabPanel switchType=ajax> , each
Let's consider the following scenario. I have the following page where all rendered elements
Consider the following code, I have a textblock that is an on/off button in
Let's say we have a particularly simple function like import scipy as sp def
Consider the following: I have a .NET 3.5 project that uses a .NET 1.1
Consider the following scenario: I have a page that can open a dialog (jquery
Consider the following situation: I have a library that includes a third party library.
Please consider the following: we have a Spring bean B which is advised with

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.