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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:40:50+00:00 2026-06-15T00:40:50+00:00

Hey guys i want to use two arrays in on mysql UPDATE query. So

  • 0

Hey guys i want to use two arrays in on mysql UPDATE query. So here is what i have:

For example:

$ergebnis:
Array ( [0] => 100 [1] => 200 [2] => 15 )


$Index:
Array ( [0] => 3 [1] => 8 [2] => 11 )

And this is what i tried:

UPDATE `lm_Artikel` 
SET Bestand='".$ergebnis."' 
WHERE `Index` = '".$Index."'

This query seems not to work. I don’t know why i enabled php error reporting and there are no errors and when i run the query it doesn’t change anything in my database. Can anyone see what i did wrong?

  • 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-15T00:40:51+00:00Added an answer on June 15, 2026 at 12:40 am

    You need to do it for each element of your arrays, hence, you can use the foreach() function:

    foreach($ergebnis as $key => $value){
        $sql = "UPDATE lm_Artikel SET Bestand='".$value."' WHERE `Index` = '".$Index[$key]."'";
        mysqli_query($sql);
    }
    

    P.S. There could well be a pure-sql alternative but I’m not too SQL-hot, so I’ll leave it to someone who has more expertise.

    Also, please note that it may be easier for you to set the index as the array keys:

    $ergebnis = Array(3=>100, 8=>200, 11=>15);
    

    And then the foreach() would look a little better:

    foreach($ergebnis as $key => $value){
        $sql = "UPDATE lm_Artikel SET Bestand='".$value."' WHERE `Index` = '".$key."'";
        mysqli_query($sql);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I have an assigned array from mysql results and I simply want
Hey guys. I have the following situation. I want to use a TypeDescriptor to
Hey guys I have a weird problem trying to use a global array in
Hey guys quick question, I want to update the contents of a div with
Hey guys, I'm trying to add a textfield.text entry to an array. I want
Hey guys, I have an application that I want to display some data from
hey guys, beginner here. I have written a program that outputs files to .txt's
Hey guys I have an array of dictionaries plist file that I am reading
Hey guys, I have some code that I found that I would rather use
Hey guys, I want to make a function loop over all elements that have

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.