How to update 3 table existing data by id in codeigniter

Keywords´╝Ü php mysql codeigniter

Question: 

I have data that already exists in the database server and I want to change it based on the id table. I want to update one time so that the 3 data tables are updated as well because the table id is in another table too. I tried it but I can't. Please help me

I have joined from several tables. I've also searched on :link! :link!

This is my Controller

public function updateservicenew(){
$id= $this->uri->segment(3);
$data['vendor']= $this->model_vendor->show_data_all();
$data['vendor2']= $this->model_vendor->show_data_vendor2();
$data['service']= $this->Madmin2->getservicenew($id)->row_array();
$this->template->viewadmin2('admin2/transaks/updateservicenew',$data);
}
public function saveservicenew(){
$this->Madmin2->saveservicenew($this->input->post());
redirect(base_url('admin2/transaksidone'));
}

This is my Model

public function getservicenew($id){     $this->db->select('kontak_sis.*,vendor.*,vendor2.*,service_sis.*,sumber_info.*,provinsi.*,kota.*,mst_service.*,service.*');
$this->db->from('service_sis');
$this->db->join('vendor', 'service_sis.id_vendor=vendor.id_vendor', 'left');
$this->db->join('vendor2', 'service_sis.id_vendor2=vendor2.id_vendor2', 'left');
$this->db->join('mst_service', 'service_sis.id_mst_service=mst_service.id_mst_service', 'left');
$this->db->join('kontak_sis', 'service_sis.id_kontak=kontak_sis.id_kontak', 'left');
$this->db->join('sumber_info', 'service_sis.id_sumber=sumber_info.id_sumber', 'left');
$this->db->join('provinsi', 'service_sis.id_provinsi=provinsi.id_provinsi', 'left');
$this->db->join('kota', 'service_sis.id_kota=kota.id_kota', 'left');
$this->db->join('service', 'service_sis.id_service=service.id_service', 'left');
$param = array('service_sis.id_service'=>$id);
return $this->db->get_where('',$param);
}
public function simpanservicenew(){
$data_pelanggan['cid']= $this->input->post('cid');
$data_pelanggan['nama_perusahaan']= $this->input->post('nama_perusahaan');
$data_pelanggan['destination']= $this->input->post('destination');
$data_pelanggan['alamat_perusahaan']= $this->input->post('alamat_perusahaan');
$data_pelanggan['pic_perusahaan']= $this->input->post('pic_perusahaan');
$data_pelanggan['telepon_pic']= $this->input->post('telepon_pic');
$data_pelanggan['fax']= $this->input->post('fax');
$data_pelanggan['hp']= $this->input->post('hp');
$data_pelanggan['email_pic']= $this->input->post('email_pic');

$this->db->where('id_kontak',$this->input->post('id_kontak'));
$this->db->update('kontak_sis',$data_pelanggan);

$data_vendor['pic_vendor']= $this->input->post('pic_vendor');
$data_vendor['media_vendor']= $this->input->post('media_vendor');
$data_vendor['kapasitas_vendor']= $this->input->post('kapasitas_vendor');
$data_vendor['telepon_vendor']= $this->input->post('telepon_vendor');
$data_vendor['email_vendor']= $this->input->post('email_vendor');

$this->db->where('id_vendor',$this->input->post('id_vendor'));
$this->db->update('vendor',$data_vendor);

$data_vendor2['pic_vendor2']= $this->input->post('pic_vendor2');
$data_vendor2['media_vendor2']= $this->input->post('media_vendor2');
$data_vendor2['kapasitas_vendor2']= $this->input->post('kapasitas_vendor2');
$data_vendor2['telepon_vendor2']= $this->input->post('telepon_vendor2');
$data_vendor2['email_vendor2']= $this->input->post('email_vendor2');

$this->db->where('id_vendor2',$this->input->post('id_vendor2'));
$this->db->update('vendor2',$data_vendor2);

This is my View

<div class="row">
<div class="box box-primary">
<div class="box-header with-border">
<div id='progress'><div id='progress-complete'></div></div>
<h2 class="box-title"><b>Set Ewo</b></h2>
</div>
<div class="box-body">
<form method="post" action="<?php echo base_url('admin2/simpanservicebaru/'.$this->uri->segment(3)); ?>" enctype="multipart/form-data" id="myForm">
<input type="hidden" name="id_service" value="<?php echo $service['id_service']; ?>">
<input type="hidden" name="id_kontak" value="<?php echo $service['id_kontak']; ?>">
<input type="hidden" name="id_mst_service" value="<?php echo $service['id_mst_service']; ?>">
<input type="hidden" name="id_vendor" value="<?php echo $service['id_vendor']; ?>">
<input type="hidden" name="id_vendor2" value="<?php echo $service['id_vendor2']; ?>">

<fieldset>
                    <div class="form-group">
                        <label for="">Registration Form ID</label>
                        <input type="text" name="cid" class="form-control" placeholder="" value="<?php echo $service['cid'] ?>" readonly>
                    </div>
<div class="form-group">
                        <label for="">Customer</label>
                        <b><input type="text" name="nama_perusahaan" class="form-control" value="<?php echo $service['nama_perusahaan']; ?>"required></b>
                    </div>
                    <div class="form-group">
                        <label for="">Destination</label>
                        <b><input type="text" name="destination" class="form-control" placeholder="destination" 
                        value="<?php echo $service['destination']; ?>"required></b>
                    </div>
                    <div class="form-group">
                        <label for="">Address</label>
                        <b><input type="text" name="alamat_perusahaan" class="form-control" placeholder="alamat" 
                        value="<?php echo $service['alamat_perusahaan']; ?>"required></b>
                    </div>
<div class="form-group">
                        <label for="">PIC(Engineering)</label>
                        <input type="text" name="pic_perusahaan" class="form-control" placeholder="pic"
                        value="<?php echo $service['pic_perusahaan']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Phone Number</label>
                        <input type="text" name="telepon_pic" class="form-control" placeholder="phone number" 
                        value="<?php echo $service['telepon_pic']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Fax</label>
                        <input type="text" name="fax" class="form-control" placeholder="fax" 
                        value="<?php echo $service['fax']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">HP</label>
                        <input type="text" name="hp" class="form-control" placeholder="hp"
                        value="<?php echo $service['hp']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Email</label>
                        <input type="text" name="email_pic" class="form-control" placeholder="email pic" 
                        value="<?php echo $service['email_pic']; ?>">
                    </div>
</fieldset>
                    <fieldset>
                    <div class="form-group">
                        <label for="">Vendor1</label>
                        <select name="id_vendor" class="form-control">
                        <option value="0">Non Vendor</option>

                    <?php
                    foreach ($vendor as $c)
                    { ?>
                      <?php $sel = ($c->id_vendor==$service['id_vendor']) ? 'selected' :''; ?>
                             <option value="<?php echo $c->id_vendor;?>" <?php echo $sel;?>><?php echo $c->nama_vendor;?></option>
                    <?php }   ?>

                    </select>
                    </div>
                    <div class="form-group">
                        <label for="">PIC</label>
                        <input type="text" name="pic_vendor" class="form-control" placeholder="pic vendor" 
                        value="<?php echo $service['pic_vendor']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Media</label>
                        <input type="text" name="media_vendor" class="form-control" placeholder="media" 
                        value="<?php echo $service['media_vendor']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Capacity</label>
                        <input type="text" name="kapasitas_vendor" class="form-control" placeholder="kapasitas vendor" 
                        value="<?php echo $service['kapasitas_vendor']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Phone</label>
                        <input type="text" name="telepon_vendor" class="form-control" placeholder="telepon vendor" 
                        value="<?php echo $service['telepon_vendor']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Email</label>
                        <input type="text" name="email_vendor" class="form-control" placeholder="email vendor" 
                        value="<?php echo $service['email_vendor']; ?>">
                    </div>
                    <hr></hr>

                    <div class="form-group">
                        <label for="">Vendor2</label>
                        <select name="id_vendor2" class="form-control">
                        <option value="0">Non Vendor</option>

                    <?php
                    foreach ($vendor2 as $c)
                    { ?>
                      <?php $sel = ($c->id_vendor2==$service['id_vendor2']) ? 'selected' :''; ?>
                             <option value="<?php echo $c->id_vendor2;?>" <?php echo $sel;?>><?php echo $c->nama_vendor2;?></option>
                    <?php }   ?>

                    </select>
                    </div>
                    <div class="form-group">
                        <label for="">PIC</label>
                        <input type="text" name="pic_vendor2" class="form-control" placeholder="pic vendor" 
                        value="<?php echo $service['pic_vendor2']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Media</label>
                        <input type="text" name="media_vendor2" class="form-control" placeholder="media" 
                        value="<?php echo $service['media_vendor2']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Capacity</label>
                        <input type="text" name="kapasitas_vendor2" class="form-control" placeholder="kapasitas vendor" 
                        value="<?php echo $service['kapasitas_vendor2']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Phone</label>
                        <input type="text" name="telepon_vendor2" class="form-control" placeholder="telepon vendor"
                        value="<?php echo $service['telepon_vendor2']; ?>">
                    </div>
                    <div class="form-group">
                        <label for="">Email</label>
                        <input type="text" name="email_vendor2" class="form-control" placeholder="email vendor" 
                        value="<?php echo $service['email_vendor2']; ?>">
                    </div>
                    </fieldset>
                    <fieldset>
                    <br>
                        <p>*Pastikan semua form sudah terisi dengan benar</p>
                    <button id="submit" class="btn btn-success">Update Service</button>
                    </fieldset>

            </div>
        </div>
    </div>
</div>
<script>
   $( function() {
      var $signupForm = $( '#myForm' );
      $signupForm.validate({errorElement: 'em'});
      $signupForm.formToWizard({
      submitButton: 'submit',
      nextBtnName:  'Selanjutnya',
      prevBtnName:  'Sebelumnya',
      nextBtnClass: 'btn btn-primary btn-flat next',
      prevBtnClass: 'btn btn-default btn-flat prev',
      buttonTag:    'button',
      validateBeforeNext: function(form, step) {
          var stepIsValid = true;
          var validator = form.validate();
          $(':input', step).each( function(index) {
              var xy = validator.element(this);
              stepIsValid = stepIsValid && (typeof xy == 'undefined' || xy);
          });
          return stepIsValid;
      },
      progress: function (i, count) {
          $('#progress-complete').width(''+(i/count*100)+'%');
      }

      });
   });
</script>

 I want to update one time so that the 3 data tables are updated as well because the table id is in another table too.Thank you for the help

Answers: