I have to sync with two tables in the database
The following is the error I get:
A database error has occurred
Error Number: 1054
Unknown column 'Array' in 'field list'
INSERT INTO client (interior_client_name, Interior_client_email, interior_client_mobile, interior_house_id) VALUES ('a', 'b', '8989898', Array)
Filename: C:\xampp\htdocs\ThinkInterio\system\database\DB_driver.php
Line Number: 330

These are the two tables as shown below :
7400349fe74803470d45f538156f8fce

The view file template is as follows:

<form id="formID" class="formular" method="post" action="<?php echo base_url(); ?>admin/startdetails" enctype="multipart/form-data">  
                    <!-- Start Content Start -->
                    <div class="visualizeContent" style="display:block;" id="start">
                        <h1>Start</h1>
                        <ul>
                            <li class="heading">Client Details</li>
                            <li class="clearfix">
                                <div class="leftLabelName">Client Name</div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="text" name="interior_client_name" class="validate[required]"/></div>
                            </li>
                            <li class="clearfix">
                                <div class="leftLabelName">Client Email ID</div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="text" name="Interior_client_email" class="validate[required]"/></div>
                            </li>
                            <li class="clearfix">
                                <div class="leftLabelName">Client Contact Number</div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="text" name="interior_client_mobile" class="validate[required]" /></div>
                            </li>
                            <li class="heading">
                                Basic Details
                            </li>
                            <li class="clearfix">
                                <div class="leftLabelName">House Type</div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent">
<select name="interior_house" id="interior_house_desc" class="validate[required]">
                                    <option value="">Please select</option>
                                    <?php foreach($house as $ho){ ?>
                                    <option value="<?php echo $ho('interior_house_id');?>"><?php echo $ho['interior_house_desc'];?></option>
                                    <?php } ?>
                                </div>
                            </li>
                            <li class="clearfix">
                                <div class="leftLabelName"><strong>Carpet Area</strong></div>
                                <div class="middleDivider"></div>
                                <div class="RightContent"><input type="text" name="Interiror_client_carpet_area" class="validate[required]"/></div>
                            </li>

                           <?php foreach($roomtype as $co){
                                 ?>
                            <li class="clearfix">

                                <div class="leftLabelName"><?php echo $co['interior_room_desc']?></div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="text" name="roomType[<?php echo $co['interior_room_id']?>]" /></div>
                            </li> <?php } ?>

                            <li class="clearfix">
                                <div class="leftLabelName">Upload Floor Plan <small style="color:#A4A3A3;">(Max 1MB)</small></div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="file" /></div>
                            </li>
                            <li class="clearfix nextPrev displayNone">
                                <div class="leftLabelName">&nbsp;</div>
                                <div class="middleDivider">&nbsp;</div>
                                <div class="RightContent">
                                    <input type="submit" class="previous" value="Previous" />
                                    <input type="submit" class="next" value="Next" />
                                </div>
                            </li>
                        </ul>
                    </div><!-- Start Content End -->

My functions are as follows in the controller, can anyone help me with what has gone wrong? I have to post values in those two tables, and I have tried something on the lines of those. below

public function starting()
  //start in interior table
   {
    $data['house']=$this->db->get('house')->result_array();
    $data[]=$this->db->get('rooms')->result_array();
    $data['body_content']='template/client';
    $this->load->view('template/admin', $data);   
    }
public function startdetails()
{
echo"<pre>";
print_r($_POST);

$data['interior_client_name']=$_POST['interior_client_name'];   
$data['Interior_client_email']=$_POST['Interior_client_email']; 
$data['interior_client_mobile']=$_POST['interior_client_mobile'];
$data['interior_house_id']=$_POST['interior_house'];

$this->db->insert('client',$data);  
$roomTypes =explode(',', $this->input->post('roomType'));   
$startid=$this->db->insert_id();
print_r($startid);
print_r($roomTypes);
foreach($roomTypes as $key=>$roomType){
                $clientData=array(
                //'interior_client_trans_ref_id'=>'client.interior_client_trans_ref_id',
                'interior_client_trans_no_room_id' => $key,
                'interior_house_no_rooms' => $roomType
                );  
$this->think_model->insert('client_trans',$clientData);
                echo '<pre>';
                print_r($clientData);

            }

echo"<pre>";print_r($data);exit; 
$this->db->set('se_erm_client_id', $data);

/*
$rdata['interior_house_no_rooms']=$_POST['bedroom'];    
$rdata['interior_house_no_rooms']=$_POST['living']; 
$rdata['interior_house_no_rooms']=$_POST['dining'];
$rdata['interior_house_no_rooms']=$_POST['pooja'];  
$rdata['interior_house_no_rooms']=$_POST['kitchen'];    
$rdata['interior_house_no_rooms']=$_POST['washroom'];
$rdata['interior_house_no_rooms']=$_POST['balcony'];    
$rdata['interior_house_no_rooms']=$_POST['utility'];    
$rdata['interior_house_no_rooms']=$_POST['other'];
$this->db->set('interior_house_no_rooms', $startid);
$this->db->insert('client_trans',$rdata); */
foreach($_POST['user'] as &$user)
 {
   // $user['additional_data'] = $_SESSION['additional_data'];
  //  $user['current_time'] = time();
    $this->db->insert('client_trans', $user);
 }

}

I have attached the file view, as in how it looks. Please help me, as to how to?

For some reason the variable in line 17 contains an array. Debug that value to see if it's set and read correctly.

Hi Pritaeas, Look in line 21 of the view file that I have posted. Isn't it like a select function dropdown? Like I enter in the master table of 'house'(as in the type of houses, independent, villa, etc etc) I have gotten the values from the database table 'house' to the dropdown. I'm not sure, though. I'm confused tbh. Please explain a bit more, if I'm wrong or I couldn't understand. Thanks for the response.

I understand that at first glance it looks like it should work. That's why I suggested to debug the values involved to see if something has gone wrong.

Line 32:

<option value="<?php echo $ho('interior_house_id');?>"><?php echo $ho['interior_house_desc'];?></option>

Change $ho('interior_house_id') to $ho['interior_house_id'] and it should work. Also I suggest you to use $this->input->post() instead of $_POST since it sanitized by the framework (if $config['global_xss_filtering'] = TRUE;). Bye!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.