Maaf numpang nanya caranya upload foto di CI gimana yaa? saya bingung di MVC nya

Controller (Siswa.php)

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Siswa extends CI_Controller {
	function __construct(){
	parent::__construct();
	$this->load->model('MSiswa');
	}

	public function index()
	{
		if($this->session->userdata('Login'))
		{
			$data['content']='VBlank';
			$this->load->view('VBackend',$data);
		}
		else
		{
			 redirect(site_url('Login'));
		}

	}

	public function DataSiswa()
	{

		if($this->uri->segment(4)=='view')
		{
		  $nisn=$this->uri->segment(3);
		   $tampil=$this->MSiswa->GetDataWhere('nisn',$nisn)->row();
            $data['detail']['nisn']= $tampil->nisn;
    	    $data['detail']['nis']= $tampil->nis;
            $data['detail']['nama']= $tampil->nama;
            $data['detail']['id_kelas']= $tampil->id_kelas;
            $data['detail']['alamat']= $tampil->alamat;
            $data['detail']['no_telp']= $tampil->no_telp;
            $data['detail']['id_spp']= $tampil->id_spp;
            $data['detail']['id_login']= $tampil->id_login;
			      $data['content']='Siswa/VFormUpdateSiswa';
		}
		else
		{
			$data['DataSiswa']=$this->MSiswa->GetData('siswa');
			$data['content']='Siswa/VSiswa';
		}

		$this->load->view('VBackend',$data);
	}

	public function VFormAddSiswa()
	{
		$data['content']='Siswa/VFormAddSiswa';
		$data['list_spp'] = $this->MSiswa->list_spp();
		$data['list_kelas'] = $this->MSiswa->list_kelas();
		$data['list_login'] = $this->MSiswa->list_login();
		$this->load->view('VBackend',$data);
	}
	public function AddDataSiswa()
	{
         $add['nisn']=$this->input->post('nisn');
         $add['nis']= $this->input->post('nis');
       	 $add['nama']= $this->input->post('nama');
       	 $add['id_kelas']= $this->input->post('id_kelas');
       	 $add['alamat']= $this->input->post('alamat');
       	 $add['no_telp']= $this->input->post('no_telp');
       	 $add['id_spp']= $this->input->post('id_spp');
       	 $add['id_login']= $this->input->post('id_login');
        	 $this->MSiswa->AddData('siswa',$add);
        	 redirect(site_url('Siswa/DataSiswa'));
	}

	public function UpdateDataSiswa()
	{
		 $nisn=$this->input->post('nisn');
		 $update['nis']= $this->input->post('nis');
                 $update['nama']= $this->input->post('nama');
                 $update['id_kelas']= $this->input->post('id_kelas');
                 $update['alamat']= $this->input->post('alamat');
                 $update['no_telp']= $this->input->post('no_telp');
       	         $update['id_spp']= $this->input->post('id_spp');
       	         $update['id_login']= $this->input->post('id_login');
          	$this->MSiswa->UpdateData('siswa','nisn',$nisn,$update);
		 redirect(site_url('Siswa/DataSiswa'));
	}

	public function DeleteDataSiswa()
	{
		 $nisn=$this->uri->segment('3');
        	 $this->MSiswa->DeleteData('siswa','nisn',$nisn);
        	 redirect(site_url('Siswa/DataSiswa'));
	}

}

Model (MSiswa.php)

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MSiswa extends CI_Model
{
    function AddData($tabel, $data=array())
    {
        $this->db->insert($tabel,$data);
    }

    function UpdateData($tabel,$fieldid,$fieldvalue,$data=array())
    {
        $this->db->where($fieldid,$fieldvalue)->update($tabel,$data);
    }

    function DeleteData($tabel,$fieldid,$fieldvalue)
    {
        $this->db->where($fieldid,$fieldvalue)->delete($tabel);
    }

    function GetData($tabel)
    {
        $query= $this->db->get($tabel);
        return $query->result();
    }

    function GetDataWhere($id,$nilai)
    {
        $this->db->from('kelas as a, spp as b, tbl_login as c, siswa as d');
        $this->db->where('a.id_kelas = `d`.`nisn`');
        $this->db->where('b.id_spp = `d`.`nisn`');
        $this->db->where('c.id_login = `d`.`nisn`');
        $this->db->where($id,$nilai);
        $query= $this->db->get();
        return $query;
    }
     function list_kelas()
     {
        return $this->db->get('kelas')->result();
     }

     function list_spp()
     {
        return $this->db->get('spp')->result();
     }

     function list_login()
     {
        return $this->db->get('tbl_login')->result();
     }
}

View (Siswa/VSiswa.php)

<section class="content-header">
          <h1>
            Infomasi SPP     <small>Data Siswa</small>
          </h1>
</section>

<div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title"></h3>


            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">


      <a href="<?php echo site_url('Siswa/VFormAddSiswa'); ?>" class="btn btn-primary btn-sm fa fa-plus"> Tambah Data</a><br><br>


              <table class="table table-striped">
                <tr>
                  <th>NISN</th>
                  <th>NIS</th>
                  <th>Nama Lengkap</th>
                  <th>ID Kelas</th>
                  <th>Alamat</th>
                  <th>No. Telepon</th>
                  <th>ID SPP</th>
                  <th>ID Login</th>
                  <th>Photo</th>
                  <th>Aksi</th>
                </tr>

                <?php
	if(!empty($DataSiswa))
	{
		foreach($DataSiswa as $ReadDS)
		{
	?>

	<tr>

    <td><?php echo $ReadDS->nisn; ?></td>
    <td><?php echo $ReadDS->nis; ?></td>
    <td><?php echo $ReadDS->nama; ?></td>
    <td><?php echo $ReadDS->id_kelas; ?></td>
    <td><?php echo $ReadDS->alamat; ?></td>
    <td><?php echo $ReadDS->no_telp; ?></td>
    <td><?php echo $ReadDS->id_spp; ?></td>
    <td><?php echo $ReadDS->id_login; ?></td>

		<td width="5%">
			<a href="<?php echo site_url('Siswa/DataSiswa/'.$ReadDS->nisn.'/view') ?>">Update</a>
      <td>
      <a href="<?php echo site_url('Siswa/DeleteDataSiswa/'.$ReadDS->nisn) ?>">Delete</a>
		</td>
	</tr>

         <?php
     }
 }
 ?>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>

Database

avatar kennedysunjoto_google
@kennedysunjoto_google

2 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban