Click here to Skip to main content
15,846,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My apology, I added new fields in table and didn't added field names in allowedFields variable of Model, which was causing not to update the table.


I wanted to Update Record in Database but its not updating record without showing any error.

The message Fee Receipt Updated Successfully is showing up but record is not updating.

Fee receipt updated successfully popsup but record not updating

Don't know what is wrong in my code.

Below is my View editreceipt:

<table class="table table-bordered table-striped table-hover">
    <form method="POST" action="<?php echo base_url(); ?>/FeeReceipts/updatereceipt" >
    <?php foreach($results as $row){ ?>
    <th>Institution: </th> <td><?php echo $row->institutionname; ?>
    <input type="hidden" name = "id" value="<?php echo $row->receiptno; ?>" /> </td>
    <th>Session: </th> <td><?php echo $row->sessionname; ?></td>
    <th>Class: </th> <td><?php echo $row->classname; ?></td>
    <th>Section: </th> <td><?php echo $row->sectionname; ?></td>
    <th>Admission No: </th> <td><?php echo $row->admissionno; ?></td>
    <th>Name: </th> <td><?php echo $row->studentname; ?></td>
    <th>Class Fee: </th> <td><?php echo $row->classfee; ?></td>
    <th>Discount: </th> <td><?php echo $row->totaldiscount; ?></td>

    <?php $payable = $row->classfee - $row->totaldiscount; ?>
    <th>Payable: </th> <td><?php echo $payable; ?></td>
    $p = "";
      $p = '<input type="checkbox" checked="false" class="form-control" onclick="return false;" />';
        $p = '<input type="checkbox" checked="true" class="form-control" onclick="return false;" />';
    <th>Paid: </th> <td><?php echo $p; ?></td>
    <th>Addition Fee: </th> <td><input type="text" name = "additionalfee" value="<?php echo $row->additionalfee; ?>" /> </td>
    <th>Instant Discount: </th> <td><input type="text" name = "instantdisc" value="<?php echo $row->instantdisc; ?>" /></td>
    <th>Remarks: </th> <td><input type="text" name = "remarks" value="<?php echo $row->remarks; ?>" /> </td>
    <th>Paid Amount: </th> <td><input type="text" name = "paidamount" value="<?php echo $row->paidamount; ?>" /></td>
<?php } ?>
<button type="submit" class="btn btn-success">Update Receipt</button>

What I have tried:

  public function updatereceipt()
   $model = new FeeReceiptModel();
   $id = $this->request->getVar('id');
   $data = ['additionalfee' => $this->request->getVar('additionalfee'),
   'instantdisc' => $this->request->getVar('instantdisc'),
   'remarks' => $this->request->getVar('remarks'),
   'paidamount' => $this->request->getVar('paidamount')];
echo "<script>alert('Fee receipt updated successfully!');window.location.href='".base_url()."/feereceipts';</script>";
Updated 7-Feb-21 20:31pm
[no name] 6-Feb-21 12:51pm    
Most probably you should give a hint how $model->update($id,$data)){ is implementd?
nyt1972 6-Feb-21 13:00pm    
Sorry I didn't understand your question but if($model->update($id,$data)){ returning successful message

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900