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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:30:14+00:00 2026-05-25T20:30:14+00:00

I want insert on a row of database table, following value with following php

  • 0

I want insert on a row of database table, following value with following php code(foreach) but after insert get following error, what do i do?

Values:

<div class="column">
    <input type="text" name="start_date[1][]" value="1111">
    <input type="text" name="end_date[1][]" value="1111">
    <input type="text" name="price_change[1][]" value="1111">
</div>
<div class="column">
    <input type="text" name="start_date[2][]" value="2222">
    <input type="text" name="end_date[2][]" value="2222">
    <input type="text" name="price_change[2][]" value="2222">
</div>
<div class="column">
    <input type="text" name="start_date[3][]" value="3333">
    <input type="text" name="end_date[3][]" value="3333">
    <input type="text" name="price_change[3][]" value="3333">
</div>

Php code:

    $residence_ups_input = $this->input->post('start_date');
    $residence_upe_input = $this->input->post('end_date');
    $residence_upc_input = $this->input->post('price_change');
    var_dump($residence_ups_input); // output this is: nobool(false)
    $residence_p = array();
    foreach ($residence_ups_input as $idx => $name) { //line 134        
        $residence_p[] = array(
            'start_date' => $residence_ups_input[$idx],
            'end_date' => $residence_upe_input[$idx],
            'price_change' => $residence_upc_input[$idx]
        );
    }
    ;
    $data = array(
        //'name' => $this -> input -> post('name'),
        'residence_p' => json_encode($residence_p)
    );
    $this->db->insert('tour_foreign', $data);

Error:

A PHP Error was encountered
Severity: Warning
Message: Invalid
argument supplied for foreach()
Filename: inser.php
Line
Number: 134

  • 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-25T20:30:14+00:00Added an answer on May 25, 2026 at 8:30 pm

    Change all columns:

    <div class="column">
        <input type="text" name="start_date[1][]" value="1111">
        <input type="text" name="end_date[1][]" value="1111">
        <input type="text" name="price_change[1][]" value="1111">
    </div>
    ....
    

    to:

    <form method="post">
    <div class="column">
        <input type="text" name="start_date[]" value="1111">
        <input type="text" name="end_date[]" value="1111">
        <input type="text" name="price_change[]" value="1111">
    </div>
    ....
    
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want insert following checkbox in a row from database table, but have error,
I want to add a row to a database table, but if a row
I want to insert a new row into a msaccess table using the following
I inserted on a row of database table values, now I want echo them
I insert several( array ) value with json_encode in one row from database table,
I want to insert a row into the Database using SqlDataAdapter. I've 2 tables
I want to insert a new row into an Access database. I'm looking at
so the problem is, that i want to insert a new row after another
I want to insert the following as the value for a variable in some
How can insert values on input in database mysql by json_encode and foreach, this

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.