CodeIgniter Forums
Edit my application previously selected item should be viewed? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Edit my application previously selected item should be viewed? (/thread-71649.html)



Edit my application previously selected item should be viewed? - kvanaraj - 09-09-2018

I want to my application previously selected items to be displayed accordingly.
How to implement this .
Controller
********
Code:
$data['getcert'] = $this->User_Model->getcert();
Model
*****
Code:
$regno = $this->session->userdata('username');
  $this->db->select('*');
  $this->db->from('certificate_det');
  $this->db->where('appdet.regno',$regno);
  $this->db->join('appdet', 'appdet.certid = certificate_det.certificate_id', 'left');
  $query = $this->db->get();
  return $query->result_array();
  echo $query;  
    }

View
*****
Code:
value="<?php echo (!isset($posted['email'])) ? '' : $posted['email'] ?>"
Is this way to fetch the details


RE: Edit my application previously selected item should be viewed? - InsiteFX - 09-10-2018

Maybe set_value from the form helper.

You need to start looking this simple stuff up yourself instead of relying on the forum users.


RE: Edit my application previously selected item should be viewed? - ignitedcms - 09-10-2018

I would store the selected values linked to the user's session data, that way you can access their selected choices on any page. Although I'm not entirely sure what you are doing.


RE: Edit my application previously selected item should be viewed? - Wouter60 - 09-10-2018

With so little code, it's hard to tell what you actually mean.
I guess you want to repopulate the form with previously made choices if the form isn't filled in completely, right?
Use the form_validation library. It is well documented on the CI website.
There's a function called set_checkbox() in the form helper too.


RE: Edit my application previously selected item should be viewed? - kvanaraj - 09-10-2018

(09-10-2018, 07:33 AM)Wouter60 Wrote: With so little code, it's hard to tell what you actually mean.
I guess you want to repopulate the form with previously made choices if the form isn't filled in completely, right?
Use the form_validation library. It is well documented on the CI website.
There's a function called set_checkbox() in the form helper too.

Code:
<?php foreach($getcert as $student){

Code:
<input type="checkbox" id="mycheck1" name="certid[]" 
       value="<?php echo set_checkbox($student['certid']) ? '1' : $student['certid'] ?>"
        class="cbx">

Code:
output
*********
Array
(
   [id] => 1
   [certificate_id] => 1
   [fee] => 500
   [APPNO] => 10001
   [regno] => 01107402042
   [certid] => 1
   [noc] => 2
   [paid] => 5000
)



RE: Edit my application previously selected item should be viewed? - Wouter60 - 09-11-2018

Don't use set_checkbox() to change the value of the checkbox, just it's checked or unchecked status!
You really should start reading the documentation!!

And once again: it won't work of you give elements the id="mycheck1" in a control structure like foreach  { }. If there are 10 checkboxes, they all have the same id. How would that help you to find the right one?

So, forget the whole id part. Use a css class to handle the checkboxes through jQuery, and an array name like "certid[]" to return the values of the checked checkboxes to your controller after submitting the form.

If you're going to use form_validation, use the "certid[]" reference too, including the square brackets. There are lots of examples for that on the internet.