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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:41:41+00:00 2026-06-05T21:41:41+00:00

My scenario is like this: <input type=file name=image[] /> <input type=file name=image[] /> <input

  • 0

My scenario is like this:

<input type="file" name="image[]" />
<input type="file" name="image[]" />
<input type="file" name="image[]" />
<input type="file" name="image[]" />

My database field table is:

ID = 1
image1 = image1.jpg
image2 = image2.jpg
image3 = image3.jpg
image4 = image4.jpg

Let’s say the row id = 1 has already had values inserted previously and if the user wants to update image1 and image 4 so they will browse and select their desired image file and they leave the image2 and image3 blank.

Here’s the concept after executing mysql query:

ID = 1
image1 = newimage1.jpg
image2 = image2.jpg
image3 = image3.jpg
image4 = newimage4.jpg

How do I do the validating query?

Currently my code is like this and I have no idea how to continue from here as I’m still new to PHP/mysql.

foreach ($_FILES['product_image']['name'] as $key => $value) {
if(!empty($value)) {
                `$upt=mysql_query("update products_list set` `image1='$pic1',image2='$pic2',image3='$pic3',image4='$pic4' where id='$id'");`
}
}

Hope this is clear to you guys. Thanks in advance. =)

  • 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-05T21:41:43+00:00Added an answer on June 5, 2026 at 9:41 pm

    You could use a counter to update the correct field:

     foreach ($_FILES['product_image']['name'] as $key => $value) {
       if(!empty($value)) {
            // field names starts from 1
            $field = 'image'.($key+1);
            mysql_query("UPDATE product_list ".
                        "SET $field = '$value' ".
                        "WHERE id = $id");
       }
     }
    

    Of course, this would mean that you would have to update the same record upto four times depending on what is sent from your form. Also, you should escape the user input using something like mysql_escape_string().

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

Sidebar

Related Questions

I want to show image in a crystal report. Scenario is something like this.
I'm trying for hours to implement a scenario like this, but with input parameters
Our current scenario is like this: we have an existing database that needs to
Here's the scenario: I have a contact form with few checkboxes: <input type=text name=cola[]
I have a scenario like this: I need to pass @id to the stored
I have a scenario like this: form = MockRepository.GenerateMock<IAddAddressForm>(); mediator = new AddAddressMediator(form); The
I got a scenario like this Class Parent { Property A; } Class A
Detailed scenario is like this : I am creating 10 buttons using a loop
I got an issue. The scenario is like this: I got an NSOperationQueue that
I have a scenario that looks like this: #include <algorithm> using namespace std; //

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.