2016-02-05 2 views
0

У меня возникла проблема с обновлением или редактированием определенных данных в отношениях от одного до многих. Вот картинка->errorОшибка при обновлении в определенных данных с помощью codeigniter

В моей базе данных у меня есть «Idcertificate», который является первичным ключом, и у меня также есть «Id» внешний ключ. Вот моя картина ->enter image description here

это мое мнение:

<div class="modal fade" id="myModals" role="dialog"> 
 
       <div style="margin-top: 100px;" class="modal-dialog modal-lg"> 
 
    
 
        <div class="modal-content"> 
 
     <div class="modal-header"> 
 
      <button type="button" class="close" data-dismiss="modal">&times;</button> 
 
      <h4 class="modal-title text-center">Certificates and Awards</h4> 
 
     </div> 
 
     <div class="modal-body"> 
 
     
 
\t \t \t 
 
      
 
       <?php 
 
       if (isset($message)){ 
 
     echo $message; 
 

 
    } else{ 
 
    foreach ($r as $index => $r) 
 
    { 
 
     
 
        ?> 
 
       <form method="POST" action="<?php echo site_url("certificates/editon/".$r->Id) ?>"> 
 
        <input class="input-lg " type="hidden" name="Id" placeholder="<?php echo $r->Id ?>" readonly=""> 
 
        <input class="input-lg " type="hidden" name="Idcertificate" placeholder="<?php echo $r->Idcertificate ?>" readonly=""> 
 
       <input class="input-lg text-capitalize" type="text" name="AwardsReceived" placeholder="Certificates/Awards Received" value="<?php echo $r->Certificates ?>" > 
 
       
 
       <input class="input-lg text-capitalize" type="text" name="Year" placeholder="Year" value="<?php echo $r->Year?>"> 
 
       <input class="input-lg text-capitalize" type="text" name="Place" placeholder="Place" value="<?php echo $r->Place ?>"> 
 
    <?php } } ?> 
 
         
 
     
 
       <br><br> <div class="modal-footer"> 
 
      
 
     <button type="submit" class="btn btn-default" >Update</button> 
 
      <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> 
 
      </div> 
 
      
 
      </form> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
     

это мой контроллер:

function editon($Id){ 
 
     
 
     
 
      
 
    
 
      
 
      $data= Array(
 
       'Idcertificate' => $this->input->post('Idcertificate'), 
 
       'Certificates' => $this->input->post('AwardsReceived'), 
 
       'Year'  => $this->input->post('Year'), 
 
       'Place' => $this->input->post('Place'), 
 
       ); 
 
       $this->db->where('Id', $Id); 
 
       $this->db->update('certificatesawardsreceived',$data); 
 
       redirect('viewstudentinalpha/index'); 
 
    } 
 
}

+0

Кто-нибудь может мне помочь? –

+0

Бит странно. Можете ли вы отправить схему таблицы. Слепой снимок может быть значением по умолчанию, равным '0'. Первичный ключ должен быть AUTO_INCREMENT NOT NULL, и вы не должны публиковать его. DB сама по себе нужно увеличить значение для следующей строки. – Tpojka

ответ

1

Попытайтесь использовать (int)

$data= array(
    'Idcertificate' => $this->input->post('Idcertificate'), 
    'Certificates' => (int)$this->input->post('AwardsReceived'), 
    'Year' => $this->input->post('Year'), 
    'Place' => $this->input->post('Place'), 
); 

$this->db->where('Id', $Id); 

$this->db->update('certificatesawardsreceived',$data); 
+0

Спасибо, сэр! @ wolfgang1983 –

Смежные вопросы