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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:21:08+00:00 2026-06-05T10:21:08+00:00

query result Array ( [0] => stdClass Object ( [ingredientID] => 2 [code] =>

  • 0

query result

Array
(
[0] => stdClass Object
    (
        [ingredientID] => 2
        [code] => Bf
        [description] => 1st Class Flour
        [volume] => 8268
        [price] => 750
        [amount_gram] => 0.02980
        [status] => Inactive
        [uom_id] => 1
        [flour] => Yes
    )

[1] => stdClass Object
    (
        [ingredientID] => 3
        [code] => Sf
        [description] => 3rd Class Flour
        [volume] => 18490
        [price] => 635
        [amount_gram] => 0.02540
        [status] => Inactive
        [uom_id] => 5
        [flour] => Yes
    )
..........

I want to store this results into another table as row inventory.
the table will look like this:

ID        inventory
1         (the result)
2         (another result)

And after I will query it back again so that I can display the result.

here’s what I have done lately.

store:

//getting the result
$inv = $this->db->get_from('table','id'=>'1')->row();
<input type="hidden" name="inventory" value="<?php print_r($inv)?>">
//storing in the new table
$this->db->insert('table2',array('inventory'=>$this->input->post('inventory')));

getting:

$inventory = $this->db->get_where('table2',array('ID'=>'1'))->row_array();
//result
array
(
      [ID] => 1
      [inventory] =>
      array
      (
            [0] => stdClass Object
            (
                 [ingredientID] => 2
                 ...... and so on

I want to display everything in the array[‘inventory’] which is an array of objects.

I’ve done this
foreach($arr[‘inventory’] as $invent):
echo $invent[‘ingredientID’];

but there’s an error in the foreach part.
error: Invalid argument supplied for foreach()

What should i do?
endforeach;

  • 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-05T10:21:09+00:00Added an answer on June 5, 2026 at 10:21 am

    assuming:

    $results = $this->db->get_where('table2',array('ID'=>'1'))->row_array();
    

    you should use this to print it

    foreach($results['inventory'] as $inventory)
    {
        print_r($inventory->ingredientID);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some code here, I want store mysql query result into an array with php,
How can I assign query result into array elements? This is my code: include('db.php');
I have coded foreach($DB->query($query) as $row){ print_r($row); which is giving result as stdClass Object
$result = $this->db->query($query)->result_array(); if($result[9]['b_code'] != FALSE) { $result_array = array( '0' => $result[0]['b_code'], '1'
I want to store the result of select query in an array in C#.
How to return my LINQ query result as a particular object public CountryTable GetSelectedEventInfo(string
I want to change some properties of a LINQ query result object without creating
i'm having some trouble trying to use a query result as an array First
I have an array (mysql query result) stored in $_SESSION variable. Now, I try
I have the following code $result = $handle->select()->from('store_products_id', array('count'=>'COUNT(store_products_id.product_id)')) ->where('store_products_id.store_id=?', $this->store_id) ->columns($selectColumns) ->join('product_quickinfo', 'store_products_id.product_id

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.