I can't update data in a record in CodeIgniter . Instead of updating it's adding new record in database table.'hotelres_id' is the primary key of my table.
I have posted the code below:-
Controller code for update:-
function edit($id){
$this->load->model('hotel_reservation','mb');
$data['message'] = '';
$data['object'] = $this->mb->find_by_id($id);
if($data['object']){
$this->form_validation->set_rules('roomno', 'Room Number', 'required|is_unique[hotel_reservation.roomno]');
$this->form_validation->set_rules('checkin', 'Check In', 'required|is_unique[hotel_reservation.checkin]');
$this->form_validation->set_rules('checkout', 'Check Out', 'required|is_unique[hotel_reservation.checkout]');
if ($this->form_validation->run() == TRUE){
$this->mb->eventreg_id = $_POST['hotelres_id'];
$this->mb->eventreg_id = $_POST['eventreg_id'];
$this->mb->eventhotel_id = $_POST['eventhotel_id'];
$this->mb->roomno = $_POST['roomno'];
$this->mb->checkin = $_POST['checkin'];
$this->mb->checkout = $_POST['checkout'];
$this->mb->comment = $_POST['comment'];
$this->mb->update();
$data['message'] = 'Details updated successfully';
$data['object'] = $this->mb;
}
$this->load->view('core/hotel_reservation/edit',$data);
}
else{
$data['message'] = 'No details available!! Fill It!!';
$this->load->view('core/hotel_reservation/save',$data);
}
}
View Code :-
<html>
<head>
<title>Hotel Reservation</title>
</head>
<body>
<h2>Hotel Reservation</h2>
<?php if(isset($message)&&$message!='') echo "<span class=\"message\">{$message}</span>"; ?>
<form action="<?php echo site_url('core/hotel_re/edit/'.#$object->hotelres_id); ?>" method="POST" >
<table class="formtable">
<tr><td>hotelres_id</td><td><input type="text" name="hotelres_id" id="hotelres_id" class="textbox" value="<?php echo #$object->hotelres_id; ?>" readonly></td></tr>
<tr><td>eventreg_id</td><td><input type="text" name="eventreg_id" class="textbox" value="<?php echo #$object->eventreg_id; ?>" readonly></td></tr>
<tr><td>eventhotel_id</td><td><input type="text" name="eventhotel_id" class="textbox" value="<?php echo #$object->eventhotel_id; ?>" readonly></td></tr>
<tr><td>Room Number</td><td><input type="text" name="roomno" value="<?php echo #$object->roomno; ?>" class="textbox" ></td></tr>
<tr><td>Check In</td><td><input type="text" name="checkin" value="<?php echo #$object->checkin; ?>" class="textbox"></td></tr>
<tr><td>Check Out</td><td><input type="text" name="checkout" value="<?php echo #$object->checkout; ?>" class="textbox"></td></tr>
<tr><td>Comment</td><td><textarea type="text" name="comment" value="<?php echo #$object->comment; ?>" class="textarea" ></textarea></td></tr>
<tr><td> </td><td><input type="submit" name="submit" value="Update" class="submitbutton"></td></tr>
</table>
</form>
<span class="validation-errors"><?php echo validation_errors(); ?></span>
</body>
</html>
Model code:-
<?php
class hotel_reservation extends CI_Model{
var $hotelres_id;
var $eventreg_id;
var $eventhotel_id;
var $roomno;
var $checkin;
var $checkout;
var $comment;
static $tablename = 'hotel_reservation';
static $tableid = 'hotelres_id';
function find_by_id($id)
{
$tableid = self::$tableid;
$resultset = $this->db->get_where(self::$tablename,array($tableid=>$id),1);
if($resultset->num_rows()==1)
return array_shift($resultset->result(get_class($this)));
return false;
}
function find_all()
{
$resultset = $this->db->get(self::$tablename);
return $resultset->result(get_class($this));
}
function save()
{
$tableid = self::$tableid;
if(isset($this->$tableid)&&$this->$tableid!=''&&$this->$tableid!=0)
$this->update();
else
$this->insert();
}
private function insert()
{
$this->db->insert(self::$tablename,$this);
}
function update()
{
$tableid = self::$tableid;
$this->db->where($tableid,$this->$tableid);
$this->db->update(self::$tablename,$this);
}
function delete()
{
$tableid = self::$tableid;
$this->db->where($tableid,$this->$tableid);
$this->db->delete(self::$tablename);
}
}
The mistake is here!!
In your controller, you have done this...
$this->mb->eventreg_id = $_POST['hotelres_id'];
$this->mb->eventreg_id = $_POST['eventreg_id'];
This should be this
$this->mb->hotelres_id = $_POST['hotelres_id'];
$this->mb->eventreg_id = $_POST['eventreg_id'];
And like i Said, the update term should be written like this...
$this->db->where($tableid,$this->hotelres_id);
Solved?
From what i can see, i think your issue is with this line:
$this->db->update(self::$tablename,$this);
As you should pass the update function an array with matching keys to your TB columns and values to be updated, with you send the whole object ($this), doesn't also send tableid and tablename?
According to your code ($this->mb->update();), it is calling mb model. But you have provided code for hotel_reservation model. May be some mismatch there.
Related
I'm trying to select one contract from the dropdown list, but it looks like the Ajax call is returning information for all contracts instead of just the id being sent. Bare in mind that I'm very new to ZF2.
// view.phtml
<script>
function loadContractId(id)
{
$.getJSON('<?php echo $this->basePath();?>/ajax/getId/'+id+'', function(data) {
$("#ctrid").text(data["arr"][0].ctr_id);
$("#ctrspec").text(data["arr"].ctr_spec);
$("#ctrnutype").text(data["arr"].ctr_nu_type);
$("#ctrlocationcity").text(data["arr"].ctr_location_c);
$("#ctrlocationstate").text(data["arr"].ctr_location_s);
$.each(data["arr"], function (index, item) {
console.log(item);
});
});
$("#contact_holder").css('visibility','visible');
}
</script>
<div id="loc_placement_panel" class="p0pup">
<form name="loc_placement_form" method="post" action="<?php echo $this->basePath(); ?>/booking/view/add">
<input type="hidden" name="ph_id" value="<?php echo $ar["ph_id"]; ?>">
<input type="hidden" name="pres_status" value="2">
<input type="hidden" name="ph_name" value="<?php echo $ar["ctct_name"]; ?>">
<!--<input type="hidden" name="addon" value="see below">-->
<strong>Placements</strong><br/><br/>
<label><strong>Contract:</strong></label>
<select name="contactlist" id="contactlist" onchange="loadContractId($('#contactlist').val())">
<?php
foreach ($ctrLT as $row=>$ar_contracts)
{
echo "<option value='".$ar_contracts['ctr_id']."'>";
echo $ar_contracts['ctr_no'];
echo "</option>";
}
?>
</select>
<div id="contact_holder" style="visibility: hidden">
<strong>Ctr id: </strong><span id="ctrid" ></span><br/>
<strong>Spec: </strong><span id="ctrspec" ></span><br/>
<strong>Nurse Type: </strong><span id="ctrnutype" ></span><br/>
<strong>City: </strong><span id="ctrlocationcity" ></span><br/>
<strong>State: </strong><span id="ctrlocationstate" ></span><br/>
</div>
<label><strong>User Name:</strong></label>
<input type="text" name="loc_location" id="loc_location" value="<?php echo $ar["ctct_name"]; ?>" />
<label><strong>$ltcontracts:</strong></label>
<textarea id="txtArea" rows="10" cols="100" name="loc_location" id="loc_location" value=""><?php '<pre>'; print_r($ltcontracts); '</pre>';?></textarea>
<br/><br/>
<!-- <input type="submit" value="Submit" id="loc_placement_submit_btn" name="loc_placement_submit_btn" /> -->
<input type="button" value="Cancel" id="loc_placement_cancel_btn" />
</form>
</div>
// AjaxController.php
// LT contracts
public function getId($id) {
$id = (int) $id;
return $this->getResortObject('retainedResort',$id);
}
// LT contracts
public function getIdAction() {
$result = new \stdClass();
$arr = $this->getContractsTable()->selectLtContracts($id);
$result->code = Response::STATUS_CODE_200;
$result->arr = $arr;
$json = Json::encode($result);
$response = $this->getResponse(); //new Response();
$response->setStatusCode($result->code);
$response->getHeaders()->addHeaders(array('Content-Type'=>'application/json'));
$response->setContent($json);
return $response;
}
// ContractTable.php
I tried also with selected id, ( $select->where('ctr_id = ?', $id); ) but it didn't work.
public function selectLtContracts($id = 0, array $ar = null) {
$this->table='allcontracts';
$select = new Select($this->table);
$select->where->like('ctr_no', '%LT');
$resultSet = $this->selectWith($select);
$ar = array();
if($resultSet)
{
$i=0;
foreach ($resultSet as $row) {
$ar[$i]['ctr_id']=$row->ctr_id;
$ar[$i]['ctr_no']=$row->ctr_no;
$ar[$i]['ctr_spec']=$row->ctr_spec;
$ar[$i]['ctr_nu_type']=$row->ctr_nu_type;
$ar[$i]['ctr_location_c']=$row->ctr_location_c;
$ar[$i]['ctr_location_s']=$row->ctr_location_s;
$ar[$i]['ctr_nurse']=$row->ctr_nurse;
$ar[$i]['ctr_type']=$row->ctr_type;
$ar[$i]['ctr_marketer']=$row->ctr_marketer;
$ar[$i]['ctr_recruiter']=$row->ctr_recruiter;
$i+=1;
}
}
return $ar;
}
This is what I'm getting from my console when I select a single contract from the dropdown list:
Any idea?
Basically I forgot to include in getIdAction() the single 'id' parameter from route:
$id = (int) $this->params()->fromRoute('id', 0);
and in the ContractsTable.php I needed to add equalTo() predicate:
...
if($id!='' && $id > 0)
$where->equalTo('ctr_id', $id);
$select->where($where);
...
I'm having some challenge updating table a form joined with session userdata from another table. Each time I run, it displays undefined function. Please let me know where I'm getting it wrong so could fix it.Please find time to review it
I'm a newbie.
Here's the controller
public function index()
{
if ( $this->session->userdata('logged_in') )
{
$id = $this->session->userdata('id');
$this->load->model('Userinfo_model');
$data['result'] = $this->Userinfo_model->get_users($id);
$this->load->view("usermain_info", $data);
}
}
public function update_user (){
$data = $this->input->post('userId');
$id = array(
'balance' => $this->input->post('balance'),
'id' => $this->input->post('id')
);
$this->Userinfo_model->update_user($id, $data);
$this->index();
}
Model
function get_users($userid)
{
if (isset($this->session->userdata['logged_in'])) {
$userid = ($this->session->userdata['logged_in']['id']);
} else {
header("location: nwpgroup/nwp2/index.php");
}
/* all the queries relating to the data we want to retrieve will go in here. */
$query = $this->db->query("SELECT * FROM walletbalance WHERE userId='$userid'");
return $query;
}
function update_user($id,$data){
if (isset($this->session->userdata['logged_in'])) {
$data = ($this->session->userdata['logged_in']['id']);
} else {
header("location: nwpgroup/nwp2/index.php");
}
$this->db->where('userId', $data);
$this->db->update('walletbalance', $id);
}
View
<form method="post" action="<?php echo base_url() . "index.php/userinfo/update_user"?>">
<?php if($result->num_rows() == 0){
echo 'No user found';
}
else {
foreach ( $result->result_array() as $new_user ){ ?>
<h4>Your name:<input value=" <?php echo $new_user['balance'] ?>" type="text" /> </h4><br />
<h4>Your name:<input value=" <?php echo $new_user['id'] ?>" type="text"/> </h4><br/>
<h4>Your name: <input value="<?php echo $new_user['userId'] ?>" type="hidden"/> </h4>
<input type="submit" id="submit" name="dsubmit" value="Update">
<?php }
}
?>
Error message
Message: Undefined property: Userinfo::$Userinfo_model
and
Message: Call to a member function update_user() on null
Thanks, I'm grateful
change your view as follows :
<form method="post" action="<?php echo base_url() . "index.php/userinfo/update_user"?>">
<?php if($result->num_rows() == 0){
echo 'No user found';
}
else {
foreach ( $result->result_array() as $new_user ){ ?>
<h4>Your name:<input value=" <?php echo $new_user['balance'] ?>" type="text" name="balance" /> </h4><br />
<h4>Your name:<input value=" <?php echo $new_user['id'] ?>" type="text" name="id" /> </h4><br/>
<h4>Your name: <input value="<?php echo $new_user['userId'] ?>" type="hidden" name="userId"/> </h4>
<input type="submit" id="submit" name="dsubmit" value="Update">
<?php }
}
?>
</form>
form will send data to server only if the element has a name
and you cannot submit a form multiple times. The above code will create update button for each row. So if you want to update all the records in a single updation, use update_batch() in codeigniter. and change view as follows :
foreach ( $result->result_array() as $new_user ){ ?>
<h4>Your name:<input value=" <?php echo $new_user['balance'] ?>" type="text" name="balance" /> </h4><br />
<h4>Your name:<input value=" <?php echo $new_user['id'] ?>" type="text" name="id" /> </h4><br/>
<h4>Your name: <input value="<?php echo $new_user['userId'] ?>" type="hidden" name="userId"/> </h4>
<?php } ?>
<input type="submit" id="submit" name="dsubmit" value="Update">
for reference : https://www.codeigniter.com/userguide3/database/query_builder.html#updating-data
In your update_user function you didn't include the usermain_info model. That is why the error is coming.
Please create constructor function and include the model in it. I have updated your code. Try with this.
<?php
function __construct() {
parent::__construct();
$this->load->library('session');
$this->load->model('Userinfo_model');
}
public function index(){
if ( $this->session->userdata('logged_in') ){
$id = $this->session->userdata('id');
$data['result'] = $this->Userinfo_model->get_users($id);
$this->load->view("usermain_info", $data);
}
}
public function update_user (){
$data = $this->input->post('userId');
$id = array(
'balance' => $this->input->post('balance'),
'id' => $this->input->post('id')
);
$this->Userinfo_model->update_user($id, $data);
$this->index();
}
?>
I'm using OOP PHP right now, and I created a few functions that pass data from a form and insert them into the database. I know all those functions work properly, but the forms in a loop wont seem to be pass.
Here's an example of how it looks:
//Input class://
<?php
class Input{
public static function exists($type='post'){
switch($type){
case 'post':
return (!empty($_POST)) ? true : false;
break;
case 'get':
return (!empty($_POST)) ? true : false;
break;
default:
return false;
break;
}
}
public static function get($item){
if(isset($_POST[$item])){
return $_POST[$item];
}else if(isset($_GET[$item])){
return $_GET[$item];
}
return '';
}
}
?>
//----------------------------------//
<?php $user = new User();
$user_id = $user->data->id; ?>
//some html//
<?php
foreach($products->results() as $row){
$pid = $row->id;
$product = $row->product;
$days = $row->days_default;
$description = $row->description;
$img = $row->img_address;
$category = $row->category;
$x++;
?>
<h4 class="item-title"><?php echo $product . $pid?></h4>
<h5 class="item-subtitle"><?php echo $category ?></h5>
<span class="timing"><?php echo $days . " days" ?></span>
<div class="itme-description"><?php echo $description ?></div>
<div>
<form action="" method="post">
<input type="hidden" name="product_id" id="product_id" value= "<?php $pid ?>">
<input type="hidden" name="days" id="days" value="<?php $days ?>">
<input type="hidden" name="user_id" id="user_id" value="<?php $user_id ?>">
<input type="submit">
</form>
</div>
<?php
if(Input::exists()){
$reminder = new Reminder();
try{
$reminder->create(
array( 'product_id'=>Input::get('product_id'),
'days'=>Input::get('days'),
'user_id'=> Input::get('user_id')));
}catch(exception $e){
die($e->getMessage());}
}
}
?>
I can't figure out how to pass the individuals forms to the server when the user hits submit.
I am creating the BindableCollection class which implements IBindableCollection.
What I want to do is CRUD operations above the collection (array of associative arrays). I have all of the CRUD functionallity, but I lack update function which doesn't work.
Code
public function updateFirstWhere($attr, $value, $updateCallback) {
$i = 0;
foreach($this->value as $data) {
if($data[$attr] == $value) {
call_user_func_array($updateCallback, $this->value[$i]);
return;
}
$i++;
}
}
When I pass the $this->value[$i] (which is all of the data inside collection) to the callback function and I do something like that:
public function deleteThePerson($sender) {
$this->collection->updateFirstWhere("id", $sender->data_id, function(&$data) {
$data["name"] = "durisvk";
});
}
I don't see the change in the data.
I want to set the name to durisvk but I can't.
Any Ideas Please?
</head>
<body>
<?php
// UPDATE CRUD element.
$idc = -1;
$naam = "";
$merk = "";
$typ = "";
$kl = "";
$con = new PDO ("mysql:host=localhost;dbname=cars_database", "root", "");
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if(isset($_GET["action"])) {
if($_GET["action"] == "edit") {
if($_SERVER["REQUEST_METHOD"] == "POST") {
$statement = $con->prepare("UPDATE cars_assigment SET Name=?, Brand=?, Type=?, Color=? WHERE Id = ?");
$statement->bindValue(1, $_POST["Name"]);
$statement->bindValue(2, $_POST["Brand"]);
$statement->bindValue(3, $_POST["Type"]);
$statement->bindValue(4, $_POST["Color"]);
$statement->bindValue(5, $_POST["Id"]);
$statement->execute();
}
$statement = $con->prepare("SELECT * FROM cars_assigment WHERE Id = ?");
$statement->bindValue(1, $_GET["Id"]);
$statement->execute();
$record = $statement->fetchObject();
if($record != false) {
$idc = $record-> Id;
$naam = $record-> Name;
$merk = $record-> Brand;
$typ = $record-> Type;
$kl =$record-> Color;
}
}
}
?>
<h1> Update </h1>
<form method="POST">
ID: <input type="text" name="Id" value="<?php echo $idc ?>">
Naam: <input type="text" name="Name" value="<?php echo $naam ?>">
Brand: <input type="text" name="Brand" value="<?php echo $merk ?>">
Type: <input type="text" name="Type" value="<?php echo $typ ?>">
Color: <input type="text" name="Color" value="<?php echo $kl ?>">
<input name="Id" type="hidden" value="<?php echo $idc; ?>"> </input>
<input type="submit" value="Save"> </input>
</form>
</body>
i have 2 textbox in loop
and i want to update their value in database when i press button.
the issue is that when i press button it updates only last textbox value .
following is my model.
function approvedHrs($taskid,$data)
{
//$this->db->where('id', $id);
$this->db->where('taskid', $taskid);
$this->db->update(MILESTONE, $data);
}
Following is my View (For lop is here)
<?php
foreach ($result as $milestone_row) {
?>
<tr id="<?php echo $milestone_row->id; ?>">
<?php
if ($is_master_admin) {
if ($i > 1) {
if ($milestone_row->userid == $userid) {
} else {
$userid = $milestone_row->userid;
echo $milestone_row->usertitle;
}
} else {
$userid = $milestone_row->userid;
echo $milestone_row->usertitle;
}
}
?>
<li class="in">
Add Bug
<div class="message">
<span class="arrow"></span>
<span class="body">
<?php
echo '<b> <U> Task Title </U>:- </b>  ';
echo $milestone_row->tasktitle;
echo '<br/>';
echo '<b> <U> Workspace Title </U>:- </b>  ';
echo $milestone_row->workspacetitle;
echo '<br/>';
echo '<b> <U> Description </U>:- </b>  ';
echo $milestone_row->description;
echo '<br/>';
echo '<b> <U> Hours </U>:- </b>  ';
echo $milestone_row->esthours;
echo 'hrs';
echo '<br/>';
echo '<b> <U> Minutes </U>:- </b>  ';
echo $milestone_row->estmin;
echo'mins';
echo '<br/>';
?>
<b><u>Approved Hours:-</u></b>
<input style="height:14px;font-size:10pt; width: 33px" type="text" id="hours" name="approvedhrs" data-required="1" value="<?php echo $milestone_row->esthours; ?>" placeholder="Hours" onkeypress="return isNumberKey(event)" />
<input style="height:14px;font-size:10pt; width: 33px" type="text" id="minutes" name="approvedmins" value="<?php echo $milestone_row->estmin; ?>" data-required="1" placeholder="Minutes" onkeypress="return isNumberKey(event)" />
Edit
<?php echo " | ";?>
Delete
<!--<span class="datetime">at <?php //echo $milestone_row->createddate; ?></span> -->
</span>
</div>
</li>
Followinf is myController
function approvedHrs($taskid)
{
if ($this->session->userdata('logged_in')){
$session_data = $this->session->userdata('logged_in');
$id = $session_data['id'];
$username = $session_data['username'];
$is_master_admin = $session_data['master'];
$imagethumb = $session_data['imagethumb'];
$pendingbug = $this->bugmodel->getBug($id, $is_master_admin);
$pendingtask = $this->taskmodel->getTask($id, $is_master_admin);
$data = '';
$data = array(
'approvedhrs' =>$this->input->post('approvedhrs'),
'approvedmins'=>$this->input->post('approvedmins')
);
// print_r($data);
// exit;
$result = $this->milestonemodel->approvedHrs($taskid,$data);
// $this->session->set_userdata('msg', $result);
redirect('task', 'refresh');
}
else
{
redirect('login', 'refresh');
}
}
When i use array like this it gives me following error
PHP Error Occured :Message: Array to string conversion
Database Error : Unknown column 'Array' in 'field list'
UPDATE milestone SET approvedhrs = Array, approvedmins = Array WHERE taskid = '17'
You should simplify your code like this
$post = $this->input->post();
$data['approvedhrs'] = $post['approvedhrs'];
$data['approvedmins'] = $post['approvedmins'];
print_r($data);
$result = $this->milestonemodel->approvedHrs($taskid,$data);
You should make sure $post['approvedhrs'] and $post['approvedmins'] do not have arrays. They could contain array when defined in the form like this
<input type='text' name="approvedhrs[]" />
<input type='text' name="approvedmins[]" />
EDIT
As you are making inputs inside loops there fore both approvedhrs and approvedmins are posted as array. Which is causing problem in updating.
EDIT
You should make the inputs in your loop like this
<input type='text' name="approvedhrs[]" />
<input type='text' name="approvedmins[]" />
Make hidden inputs for row id and task id
<input type='hidden' name="rowid[]" />
<input type='hidden' name="taskid[]" />
<input type='text' name="approvedhrs[]" />
<input type='text' name="approvedmins[]" />
And now php
$post = $this->input->post();
$data['approvedhrs'] = $post['approvedhrs'];
$data['approvedmins'] = $post['approvedmins'];
for($i=0;$i<count($data['approvedhrs']);$i++){
$update_data['approvedhrs'] = $data['approvedhrs'][$i];
$update_data['approvedmins'] = $data['approvedmins'][$i];
$taskid = $data['taskid'][$i];
print_r($update_data);
$result = $this->milestonemodel->approvedHrs($taskid,$update_data);
unset($update_data);
unset($taskid);
}
As you are passing array of data to update, you can use update_batch mentod.
In your controller, prepare the data as below.
$k= 0 ;
$data = array();
$aphrs = $this->input->post('approvedhrs'); // returns array
$apmis = $this->input->post('approvedmins'); //
foreach($aphrs as $hrs)
{
$data[] = array(
'approvedhrs' =>$hrs,
'approvedmins'=>$apmis[$k]
);
$k++;
}
// call your model function
$result = $this->milestonemodel->approvedHrs($taskid,$data);
In your model function: add update_batch method. So no need to call update method in forloop.
for update_batch, check this tutorial.
http://ellislab.com/codeigniter/user-guide/database/active_record.html#update
View
<input type='hidden' name="milestoneid[]" value ="<?php echo $milestone_row->id ?>" />
<input type="text" id="hours" name="approvedhrs[<?php echo $milestone_row->id ?>][]" value="<?php echo $milestone_row->esthours; ?>"/>
<input type="text" name="approvedmins[<?php echo $milestone_row->id ?>][]" value="<?php echo $milestone_row->estmin; ?>"/>
Controller
function approvedHrs($taskid) {
if ($this->session->userdata('logged_in')) {
$session_data = $this->session->userdata('logged_in');
$id = $session_data['id'];
$username = $session_data['username'];
$is_master_admin = $session_data['master'];
$imagethumb = $session_data['imagethumb'];
$pendingbug = $this->bugmodel->getBug($id, $is_master_admin);
$pendingtask = $this->taskmodel->getTask($id, $is_master_admin);
$data = array();
$milestoneIDs = $this->input->post('milestoneid');
$approvedhrs = $this->input->post('approvedhrs');
$approvedmins = $this->input->post('approvedmins');
foreach ($milestoneIDs as $milestoneID) {
$data = array(
'approvedhrs' => isset($approvedhrs[$milestoneID]) ? $approvedhrs[$milestoneID] : '',
'approvedmins' => isset($approvedmins[$milestoneID]) ? $approvedmins[$milestoneID] : '',
);
$this->milestone_model->approvedHrs($milestoneID,$data);//change this model name as per you use
unset($data);
}
redirect('task', 'refresh');
} else {
redirect('login', 'refresh');
}
}
Model
function approvedHrs($milestoteid, $data) {
//$this->db->where('id', $editid);
$this->db->where('milestoteid', $milestoteid);
$this->db->update(MILESTONE, $data);
}