7.Deleting data on the database


Easy Steps:

1.     On your notepad++, edit the jobseeker_list_view.php in C:\xampp\htdocs\application\views with  the following code:
<html>
<head>
<title>Jobseekers | BizjobFinder</title>
<link href='<?php echo base_url()?>css/style.css' rel='stylesheet' type='text/css'></link>
</head>
<body>
<?php if(!empty($jobseekers)){?>
<div>Total Jobseekers: <?php echo count($jobseekers); ?></div>
   <div>
      <table id="tbl">
                  <tr>
                              <th>ID</th>
                              <th>Name</th>
                              <th>Address</th>
                              <th>Action</th>
                  </tr>
                  <?php
                              foreach($jobseekers as $jobseeker) { ?>
                                          <tr class="row">
                                                      <td><?php echo $jobseeker['id']?></td>
                                                      <td><?php echo $jobseeker['lastname'].'
                                                                                    '.$jobseeker['firstname'].'
                                                                                    '.$jobseeker['mi']?></td>
                                                      <td><?php echo $jobseeker['street_barangay'].'
                                                                                    '.$jobseeker['town_city'].'
                                                                                    '.$jobseeker['province']?></td>
                                                      <td>
                                                       <a href="<?php echo base_url()?>jobseeker-edit-<?php echo
                                                                                     $jobseeker['id']?>">Edit</a> |
                                                       <a href="<?php echo base_url()?>jobseeker-delete-<?php echo
                                                                                     $jobseeker['id']?>">Delete</a>
                                                      </td>
                                          </tr>
                  <?php } ?>
      </table>
   </div>
   <?php } else { ?>
   <div>
                  <?php echo $msg; ?>
   </div>
   <?php }?>
</body>
</html>

2.     Edit routes.php located on: C:\xampp\htdocs\application\config by adding the following code:
$route['jobseeker-delete-(:num)'] = "jobseekers/delete/$1";

3.     Edit jobseekers.php located on: C:\xampp\htdocs\application\controllers by adding the following code:
function delete($id){
                  $result = $this->jobseeker->delete($id);
                  redirect(base_url().'jobseeker-list');
      }

4.     Edit jobseeker_model.php located on: C:\xampp\htdocs\application\models by adding the following code:
function delete($id){
                        $this->db->where('id',$id);
                        $result=$this->db->delete($this->table);
                        return $result;
}

5.     Perfect!, nice jobJ

1 comment: