How to view an update in view with codeigniter using mvc structure?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am new to Codeigniter but not on the MVC framework. I got a view where it shows a list of applicants. I want to update the applicant. When I click an update button on the applicants row or by simply clicking the status(using tag).
The goal is to update the applicants status only (not set, passed, failed, etc.). I can work with new codes and functions if my codes given cannot be understood.
****model**** "model name = activefile.php"
function updateApplicant($id, $fname, $mname, $lname, $gender, $bday, $num, $addr, $school, $crs, $srcstrat, $psdate, $psstatus, $date) {
// $datetime->format('Y-m-d H:i:s');
$data = array(
'fname' => $fname,
'mname' => $mname,
'lname' => $lname,
'gender' => $gender,
'birthday' => $bday,
'contactno' => $num,
'address' => $addr,
'institution' => $school,
'course' => $crs,
'src_strat' => $srcstrat,
'exam_date' => $date,
'ps_date' => $psdate,
'ps_status' => $psstatus,
);
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
}
****controller**** "controller name = hrrecruitment.php"
public function updateApplicant($id) {
$fname = $this->input->post('fn');
$mname = $this->input->post('mn');
$lname = $this->input->post('ln');
$gender = $this->input->post('gender');
$bday = $this->input->post('bday');
$num = $this->input->post('num');
$addr = $this->input->post('addr');
$school = $this->input->post('school');
$crs = $this->input->post('crs');
if ($this->input->post('srcstrat') == 'emprefopt') {
if ($this->input->post('empref_autocomplete_label') && $this->input->post('empref')) {
$srcstrat = 'empref_' . $this->input->post('empref');
} else {
$srcstrat = 'empref_' . $this->input->post('emprefhid');
}
} else if ($this->input->post('srcstrat') == 'others') {
$srcstrat = 'others_' . $this->input->post('others');
} else {
$srcstrat = $this->input->post('srcstrat');
}
$psdate = $this->input->post('psdatehid');
$psstatus = $this->input->post('psstatus');
if ($psstatus != 'Not Set' && $psdate == '0000-00-00') {
$psdate = date('Y-m-d');
}
$date = $this->input->post('exam');
if ($date != '0000-00-00' && $date) {
$this->add_recruitment($id, $date);
}
if ($this->input->post('pscheck') == 'changed') {
$this->Activefile->updateHistory($id, $this->user->get_fullName());
}
$this->Activefile->updateApplicant($id, $fname, $mname, $lname, $gender, $bday, $num, $addr, $school, $crs, $srcstrat, $psdate, $psstatus, $date);
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
}
codeigniter codeigniter-3
add a comment |
I am new to Codeigniter but not on the MVC framework. I got a view where it shows a list of applicants. I want to update the applicant. When I click an update button on the applicants row or by simply clicking the status(using tag).
The goal is to update the applicants status only (not set, passed, failed, etc.). I can work with new codes and functions if my codes given cannot be understood.
****model**** "model name = activefile.php"
function updateApplicant($id, $fname, $mname, $lname, $gender, $bday, $num, $addr, $school, $crs, $srcstrat, $psdate, $psstatus, $date) {
// $datetime->format('Y-m-d H:i:s');
$data = array(
'fname' => $fname,
'mname' => $mname,
'lname' => $lname,
'gender' => $gender,
'birthday' => $bday,
'contactno' => $num,
'address' => $addr,
'institution' => $school,
'course' => $crs,
'src_strat' => $srcstrat,
'exam_date' => $date,
'ps_date' => $psdate,
'ps_status' => $psstatus,
);
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
}
****controller**** "controller name = hrrecruitment.php"
public function updateApplicant($id) {
$fname = $this->input->post('fn');
$mname = $this->input->post('mn');
$lname = $this->input->post('ln');
$gender = $this->input->post('gender');
$bday = $this->input->post('bday');
$num = $this->input->post('num');
$addr = $this->input->post('addr');
$school = $this->input->post('school');
$crs = $this->input->post('crs');
if ($this->input->post('srcstrat') == 'emprefopt') {
if ($this->input->post('empref_autocomplete_label') && $this->input->post('empref')) {
$srcstrat = 'empref_' . $this->input->post('empref');
} else {
$srcstrat = 'empref_' . $this->input->post('emprefhid');
}
} else if ($this->input->post('srcstrat') == 'others') {
$srcstrat = 'others_' . $this->input->post('others');
} else {
$srcstrat = $this->input->post('srcstrat');
}
$psdate = $this->input->post('psdatehid');
$psstatus = $this->input->post('psstatus');
if ($psstatus != 'Not Set' && $psdate == '0000-00-00') {
$psdate = date('Y-m-d');
}
$date = $this->input->post('exam');
if ($date != '0000-00-00' && $date) {
$this->add_recruitment($id, $date);
}
if ($this->input->post('pscheck') == 'changed') {
$this->Activefile->updateHistory($id, $this->user->get_fullName());
}
$this->Activefile->updateApplicant($id, $fname, $mname, $lname, $gender, $bday, $num, $addr, $school, $crs, $srcstrat, $psdate, $psstatus, $date);
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
}
codeigniter codeigniter-3
add a comment |
I am new to Codeigniter but not on the MVC framework. I got a view where it shows a list of applicants. I want to update the applicant. When I click an update button on the applicants row or by simply clicking the status(using tag).
The goal is to update the applicants status only (not set, passed, failed, etc.). I can work with new codes and functions if my codes given cannot be understood.
****model**** "model name = activefile.php"
function updateApplicant($id, $fname, $mname, $lname, $gender, $bday, $num, $addr, $school, $crs, $srcstrat, $psdate, $psstatus, $date) {
// $datetime->format('Y-m-d H:i:s');
$data = array(
'fname' => $fname,
'mname' => $mname,
'lname' => $lname,
'gender' => $gender,
'birthday' => $bday,
'contactno' => $num,
'address' => $addr,
'institution' => $school,
'course' => $crs,
'src_strat' => $srcstrat,
'exam_date' => $date,
'ps_date' => $psdate,
'ps_status' => $psstatus,
);
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
}
****controller**** "controller name = hrrecruitment.php"
public function updateApplicant($id) {
$fname = $this->input->post('fn');
$mname = $this->input->post('mn');
$lname = $this->input->post('ln');
$gender = $this->input->post('gender');
$bday = $this->input->post('bday');
$num = $this->input->post('num');
$addr = $this->input->post('addr');
$school = $this->input->post('school');
$crs = $this->input->post('crs');
if ($this->input->post('srcstrat') == 'emprefopt') {
if ($this->input->post('empref_autocomplete_label') && $this->input->post('empref')) {
$srcstrat = 'empref_' . $this->input->post('empref');
} else {
$srcstrat = 'empref_' . $this->input->post('emprefhid');
}
} else if ($this->input->post('srcstrat') == 'others') {
$srcstrat = 'others_' . $this->input->post('others');
} else {
$srcstrat = $this->input->post('srcstrat');
}
$psdate = $this->input->post('psdatehid');
$psstatus = $this->input->post('psstatus');
if ($psstatus != 'Not Set' && $psdate == '0000-00-00') {
$psdate = date('Y-m-d');
}
$date = $this->input->post('exam');
if ($date != '0000-00-00' && $date) {
$this->add_recruitment($id, $date);
}
if ($this->input->post('pscheck') == 'changed') {
$this->Activefile->updateHistory($id, $this->user->get_fullName());
}
$this->Activefile->updateApplicant($id, $fname, $mname, $lname, $gender, $bday, $num, $addr, $school, $crs, $srcstrat, $psdate, $psstatus, $date);
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
}
codeigniter codeigniter-3
I am new to Codeigniter but not on the MVC framework. I got a view where it shows a list of applicants. I want to update the applicant. When I click an update button on the applicants row or by simply clicking the status(using tag).
The goal is to update the applicants status only (not set, passed, failed, etc.). I can work with new codes and functions if my codes given cannot be understood.
****model**** "model name = activefile.php"
function updateApplicant($id, $fname, $mname, $lname, $gender, $bday, $num, $addr, $school, $crs, $srcstrat, $psdate, $psstatus, $date) {
// $datetime->format('Y-m-d H:i:s');
$data = array(
'fname' => $fname,
'mname' => $mname,
'lname' => $lname,
'gender' => $gender,
'birthday' => $bday,
'contactno' => $num,
'address' => $addr,
'institution' => $school,
'course' => $crs,
'src_strat' => $srcstrat,
'exam_date' => $date,
'ps_date' => $psdate,
'ps_status' => $psstatus,
);
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
}
****controller**** "controller name = hrrecruitment.php"
public function updateApplicant($id) {
$fname = $this->input->post('fn');
$mname = $this->input->post('mn');
$lname = $this->input->post('ln');
$gender = $this->input->post('gender');
$bday = $this->input->post('bday');
$num = $this->input->post('num');
$addr = $this->input->post('addr');
$school = $this->input->post('school');
$crs = $this->input->post('crs');
if ($this->input->post('srcstrat') == 'emprefopt') {
if ($this->input->post('empref_autocomplete_label') && $this->input->post('empref')) {
$srcstrat = 'empref_' . $this->input->post('empref');
} else {
$srcstrat = 'empref_' . $this->input->post('emprefhid');
}
} else if ($this->input->post('srcstrat') == 'others') {
$srcstrat = 'others_' . $this->input->post('others');
} else {
$srcstrat = $this->input->post('srcstrat');
}
$psdate = $this->input->post('psdatehid');
$psstatus = $this->input->post('psstatus');
if ($psstatus != 'Not Set' && $psdate == '0000-00-00') {
$psdate = date('Y-m-d');
}
$date = $this->input->post('exam');
if ($date != '0000-00-00' && $date) {
$this->add_recruitment($id, $date);
}
if ($this->input->post('pscheck') == 'changed') {
$this->Activefile->updateHistory($id, $this->user->get_fullName());
}
$this->Activefile->updateApplicant($id, $fname, $mname, $lname, $gender, $bday, $num, $addr, $school, $crs, $srcstrat, $psdate, $psstatus, $date);
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
}
codeigniter codeigniter-3
codeigniter codeigniter-3
edited Nov 27 '18 at 2:48
kit
1,10431017
1,10431017
asked Nov 27 '18 at 1:53
Jesse Jesus ValenciaJesse Jesus Valencia
85
85
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It is not clear what question you are asking. But I do see that the model has a slight flaw in these three lines
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
The first line is not important to what you're doing. A call to select
is for, well... selecting data. Remove this line.
The second and third lines can be done in one call
$this->hrrecdb->update('active_file ', $data, array('active_file_id' => $id));
The function update
accepts a third argument - a WHERE clause. So, the argumnent array('active_file_id' => $id)
is saying the same thing as $this->hrrecdb->where('active_file_id', $id);
Less typing is good, yes?
The controller has one obvious problem at the end.
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
The last line will never be called because the function redirect
does not return. Instead it sends the browser to a new page and script execution ends. It's not clear what you're trying to accomplish with the call to $this->edit_info($id)
but it's never going to run.
Tip 1: The function base_url()
can accept URI segments. So, use it like this.
base_url('hrrecruitment/applicants/all')
Tip 2: The redirect()
function will figure out the base_url
for you so all you really need is
redirect('hrrecruitment/applicants/all');
Tip 3: When you find yourself writing the exact same call again and again then capture the return and use that instead. For example:
$srcstrat = $this->input->post('srcstrat');
if($srcstrat == 'emprefopt')
{
if($this->input->post('empref_autocomplete_label') && $this->input->post('empref'))
{
$srcstrat = 'empref_'.$this->input->post('empref');
}
else
{
$srcstrat = 'empref_'.$this->input->post('emprefhid');
}
}
elseif($srcstrat == 'others')
{
$srcstrat = 'others_'.$this->input->post('others');
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53491654%2fhow-to-view-an-update-in-view-with-codeigniter-using-mvc-structure%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It is not clear what question you are asking. But I do see that the model has a slight flaw in these three lines
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
The first line is not important to what you're doing. A call to select
is for, well... selecting data. Remove this line.
The second and third lines can be done in one call
$this->hrrecdb->update('active_file ', $data, array('active_file_id' => $id));
The function update
accepts a third argument - a WHERE clause. So, the argumnent array('active_file_id' => $id)
is saying the same thing as $this->hrrecdb->where('active_file_id', $id);
Less typing is good, yes?
The controller has one obvious problem at the end.
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
The last line will never be called because the function redirect
does not return. Instead it sends the browser to a new page and script execution ends. It's not clear what you're trying to accomplish with the call to $this->edit_info($id)
but it's never going to run.
Tip 1: The function base_url()
can accept URI segments. So, use it like this.
base_url('hrrecruitment/applicants/all')
Tip 2: The redirect()
function will figure out the base_url
for you so all you really need is
redirect('hrrecruitment/applicants/all');
Tip 3: When you find yourself writing the exact same call again and again then capture the return and use that instead. For example:
$srcstrat = $this->input->post('srcstrat');
if($srcstrat == 'emprefopt')
{
if($this->input->post('empref_autocomplete_label') && $this->input->post('empref'))
{
$srcstrat = 'empref_'.$this->input->post('empref');
}
else
{
$srcstrat = 'empref_'.$this->input->post('emprefhid');
}
}
elseif($srcstrat == 'others')
{
$srcstrat = 'others_'.$this->input->post('others');
}
add a comment |
It is not clear what question you are asking. But I do see that the model has a slight flaw in these three lines
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
The first line is not important to what you're doing. A call to select
is for, well... selecting data. Remove this line.
The second and third lines can be done in one call
$this->hrrecdb->update('active_file ', $data, array('active_file_id' => $id));
The function update
accepts a third argument - a WHERE clause. So, the argumnent array('active_file_id' => $id)
is saying the same thing as $this->hrrecdb->where('active_file_id', $id);
Less typing is good, yes?
The controller has one obvious problem at the end.
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
The last line will never be called because the function redirect
does not return. Instead it sends the browser to a new page and script execution ends. It's not clear what you're trying to accomplish with the call to $this->edit_info($id)
but it's never going to run.
Tip 1: The function base_url()
can accept URI segments. So, use it like this.
base_url('hrrecruitment/applicants/all')
Tip 2: The redirect()
function will figure out the base_url
for you so all you really need is
redirect('hrrecruitment/applicants/all');
Tip 3: When you find yourself writing the exact same call again and again then capture the return and use that instead. For example:
$srcstrat = $this->input->post('srcstrat');
if($srcstrat == 'emprefopt')
{
if($this->input->post('empref_autocomplete_label') && $this->input->post('empref'))
{
$srcstrat = 'empref_'.$this->input->post('empref');
}
else
{
$srcstrat = 'empref_'.$this->input->post('emprefhid');
}
}
elseif($srcstrat == 'others')
{
$srcstrat = 'others_'.$this->input->post('others');
}
add a comment |
It is not clear what question you are asking. But I do see that the model has a slight flaw in these three lines
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
The first line is not important to what you're doing. A call to select
is for, well... selecting data. Remove this line.
The second and third lines can be done in one call
$this->hrrecdb->update('active_file ', $data, array('active_file_id' => $id));
The function update
accepts a third argument - a WHERE clause. So, the argumnent array('active_file_id' => $id)
is saying the same thing as $this->hrrecdb->where('active_file_id', $id);
Less typing is good, yes?
The controller has one obvious problem at the end.
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
The last line will never be called because the function redirect
does not return. Instead it sends the browser to a new page and script execution ends. It's not clear what you're trying to accomplish with the call to $this->edit_info($id)
but it's never going to run.
Tip 1: The function base_url()
can accept URI segments. So, use it like this.
base_url('hrrecruitment/applicants/all')
Tip 2: The redirect()
function will figure out the base_url
for you so all you really need is
redirect('hrrecruitment/applicants/all');
Tip 3: When you find yourself writing the exact same call again and again then capture the return and use that instead. For example:
$srcstrat = $this->input->post('srcstrat');
if($srcstrat == 'emprefopt')
{
if($this->input->post('empref_autocomplete_label') && $this->input->post('empref'))
{
$srcstrat = 'empref_'.$this->input->post('empref');
}
else
{
$srcstrat = 'empref_'.$this->input->post('emprefhid');
}
}
elseif($srcstrat == 'others')
{
$srcstrat = 'others_'.$this->input->post('others');
}
It is not clear what question you are asking. But I do see that the model has a slight flaw in these three lines
$this->hrrecdb->select('*', 'activefile');
$this->hrrecdb->where('active_file_id', $id);
$this->hrrecdb->update('active_file ', $data);
The first line is not important to what you're doing. A call to select
is for, well... selecting data. Remove this line.
The second and third lines can be done in one call
$this->hrrecdb->update('active_file ', $data, array('active_file_id' => $id));
The function update
accepts a third argument - a WHERE clause. So, the argumnent array('active_file_id' => $id)
is saying the same thing as $this->hrrecdb->where('active_file_id', $id);
Less typing is good, yes?
The controller has one obvious problem at the end.
redirect(base_url() . 'hrrecruitment/applicants/all');
$this->edit_info($id);
The last line will never be called because the function redirect
does not return. Instead it sends the browser to a new page and script execution ends. It's not clear what you're trying to accomplish with the call to $this->edit_info($id)
but it's never going to run.
Tip 1: The function base_url()
can accept URI segments. So, use it like this.
base_url('hrrecruitment/applicants/all')
Tip 2: The redirect()
function will figure out the base_url
for you so all you really need is
redirect('hrrecruitment/applicants/all');
Tip 3: When you find yourself writing the exact same call again and again then capture the return and use that instead. For example:
$srcstrat = $this->input->post('srcstrat');
if($srcstrat == 'emprefopt')
{
if($this->input->post('empref_autocomplete_label') && $this->input->post('empref'))
{
$srcstrat = 'empref_'.$this->input->post('empref');
}
else
{
$srcstrat = 'empref_'.$this->input->post('emprefhid');
}
}
elseif($srcstrat == 'others')
{
$srcstrat = 'others_'.$this->input->post('others');
}
answered Nov 27 '18 at 3:19
DFriendDFriend
7,1021521
7,1021521
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53491654%2fhow-to-view-an-update-in-view-with-codeigniter-using-mvc-structure%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown