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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:15:45+00:00 2026-06-14T10:15:45+00:00

by one queryWell, i got two php functions. Both of them should insert some

  • 0

by one queryWell, i got two php functions. Both of them should insert some values into DB tables. So the first one

mysql_query("INSERT INTO images (thumb) VALUES ('$path')");

doing thins in cycle.
But then i nedd to add some values in other column but the problem is that all of thouse values stores in array. That how function was look like.

 function uploading_paths($names_array){
    $data = '(\'' . implode('\'),(\'', $names_array) . '\')';
    mysql_query("INSERT INTO `images` (`image_path`) VALUES $data");

}

So how can I add values from $data array in rows with already filled thumb columns by one query?
Is it possible?

  • 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-14T10:15:46+00:00Added an answer on June 14, 2026 at 10:15 am

    Try using PHP PDO for this. It lets you prepare a statement and then execute it as many times as you want. Example:

    $mysql_host = "127.0.0.1";
    $mysql_user = "root";
    $mysql_password = "";
    $mysql_database = "myShop";
    $dbLink = new PDO("mysql:host=$mysql_host;dbname=$mysql_database;charset=utf8", $mysql_user, $mysql_password, array(PDO::ATTR_PERSISTENT => true));
    $dbLink->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
    $query = $dbLink->prepare("insert into `images` (`thumb`, `path`) values (?, ?);");
    foreach ($names_array as $thumb => $path)
    {  
        $query->execute(array($thumb, $path)); // note the order as they should appear
    }
    

    Eventually you could replace the last path by:

    $query = $dbLink->prepare("insert into `images` (`thumb`, `path`) values (:thumb, :path);");
    foreach ($names_array as $thumb => $path)
    {  
        $query->execute(array(":path" => $path, ":thumb" => $thumb)); // no order restriction
    }
    

    … and you won`t have to supply the array of execute in the order you have the fields.

    Regards !

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

Sidebar

Related Questions

one question about PHP Development. I am building up some Form Fields for Calculations.
I have two models, first one is dependent on the second one, and I
One of the neat characteristics of UTF-8 is that if you compare two strings
One has txtDateReceived and second has txtVendorPackDate. Before insert will add record I have
One desktop application needs to get some services from server. For example sending some
One of my apps got rejected because it exceeded the startup time limit. The
one simple schema: Company embeds (many) Departments Company/Department references (many) Employees First i tried
One of my query to Sybase server is returning garbage data. After some investigations
One of My First View Controller's method returns an integer value which I want
I have two tables 'p_tuts' and 'h_tuts'. I'm using a method to display all

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.