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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:29:53+00:00 2026-05-31T17:29:53+00:00

I am fetching data from some tables & storing it in a variable like

  • 0

I am fetching data from some tables & storing it in a variable like below-:

$result = mysql_query("SELECT * FROM sample where column=mysql_insert_id()");
while($row=mysql_fetch_array($result))
{
   $str = "'". $row["name"] . "',". "'" . $row[quantity] . "'," . "'" . $row["id"];
}

So in my variable $str, suppose I have following values-:

 shirt,10,1,pant,50,2....i.e. it will store values in a comma separated format.

Now I want to insert these values in another table say test-:

$qry = "INSERT INTO test(name,quantity,id)values(".$str.");

Now I want to store values in test table in two rows like-:

shirt    10   1
pant     50   2

So how to do the same for Mysql & Oracle tables?

Plz help

See my below query-:

    $query2 = "SELECT sfoi.name, sfoi.sku, sfoi.qty_ordered, sfoi.price, sfoi.row_total, sfo.base_subtotal, sfo.base_shipping_amount, sfo.base_grand_total,
    (select mso.order_primary from mysql_sales_order mso where mso.increment_id =sfo.increment_id) 
    FROM sales_flat_order sfo
    JOIN sales_flat_order_item sfoi
    ON sfoi.order_id = sfo.entity_id
    WHERE sfo.increment_id = ". $order_id ;
$result_query2 = mysql_query($query2);

So for one order id i.e. for one order may contain more than 1 products i.e. many name,sku,quantity ordered etc. So at the time of mysql_fetch_array(), I want all product data in a single variable…my code for fetching is like this-:

while($row = mysql_fetch_array($result_query2))
{
$string = "'". $row["name"] . "',". "'" . $row["sku"] . "'," . "'" . $row["qty_ordered"] . "',". "'" . $row["price"] . "'," . "'" . $row["row_total"] . "'," . "'" . $row["base_subtotal"]. "'," . "'" . $row["base_shipping_amount"] . "'," . "'" . $row["base_grand_total"] ."'," . $row["prod_foreign"];
$query3 = "INSERT into mysql_sales_product(name, sku, qty_ordered, price, row_total, base_subtotal,base_shipping_amount,base_grand_total,prod_foreign) VALUES(".$string.")";

} 
$result_query_product_outbound = mysql_query($query3);

Here I want to store result of mysql_ fetch_array in variable in such a way that if there are multiple rows I can still able to pass those rows using variable$string. e.g-:

name   sku qty_ordered  price  row_total  subtotal shipping_amnt grand_total prod_foreign            
nokia   nk      2        500      1000      1000      300            1300         11
sansung sam     3        400      1200      1200      500            1700         30
sony    sny     4        200       800       800      200             1000         45
  • 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-05-31T17:29:54+00:00Added an answer on May 31, 2026 at 5:29 pm

    For Oracle, like below :

    INSERT ALL
       INTO your_table(column1,column2,column3) VALUES('values1.1', 'values1.2', 'values1.3')
       INTO your_table(column1,column2,column3) VALUES('values2.1', 'values2.2', 'values2.3')
    SELECT * FROM dual;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fetching some data from a database like this $sql =SELECT * FROM
I got the below error while fetching some data from sever. While fetching data,
I'm fetching some data from an MSSQL table using the mssql_fetch_object, but the text
I'm fetching data from all 3 tables at once to avoid network latency. Fetching
I'm having a problem with fetching some data. The tables I have (for testing
I'm getting some weird thing happening with my javascript. I'm fetching data from the
I am fetching some data from database and want to show these values in
I want to break my string using javascript which is fetching some data from
I am having one array where i am fetching data from database for some
I'm fetching some data from FB using the following code: dynamic parameters = new

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.