first commit
This commit is contained in:
commit
27c9266c66
13 files changed
+704
No files matched your search
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* Bootstrap v2.3.2
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img,.google-maps img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}label,select,button,input[type="button"],input[type="reset"],input[type="submit"],input[type="radio"],input[type="checkbox"]{cursor:pointer}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover,a:focus{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.127659574468085%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.84042553Line truncated
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
class Database
|
||||
{ private $db_host = 'localhost';
|
||||
private $db_user = 'project';
|
||||
private $db_pass = '';
|
||||
private $db_name = 'rai_crud';
|
||||
|
||||
private $connection = false;
|
||||
protected $result = array();
|
||||
|
||||
public function connect(){
|
||||
if(!$this->connection){
|
||||
$mycon = @mysql_connect($this->db_host,$this->db_user,$this->db_pass);
|
||||
if($mycon){
|
||||
$selectdb = @mysql_select_db($this->db_name,$mycon);
|
||||
if($selectdb){
|
||||
$this->connection = true;
|
||||
return true;
|
||||
}else{
|
||||
echo "Tidak Menemukan Database";
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
echo "Tidak bisa tersambung ke mysql";
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function disconnect(){
|
||||
if($this->connection){
|
||||
if(@mysql_close()){
|
||||
$this->connection = false;
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function select($table, $rows = '*', $where = null, $order = null){
|
||||
$q = 'SELECT '.$rows.' FROM '.$table;
|
||||
if($where != null) $q .= ' WHERE '.$where;
|
||||
if($order != null) $q .= ' ORDER BY '.$order;
|
||||
//echo $q;
|
||||
if($this->tableExists($table)){
|
||||
//echo $q;
|
||||
$query = @mysql_query($q);
|
||||
if($query){
|
||||
|
||||
$this->numRows = mysql_num_rows($query); //retrieves the number of rows from the query
|
||||
for($i = 0; $i < $this->numRows; $i++)
|
||||
{
|
||||
$r = mysql_fetch_array($query); //mysql_fetch_array returns an array that corresponds to the fetched row
|
||||
$key = array_keys($r); //array_keys() returns the keys, numeric and string, from the input array.
|
||||
for($x = 0; $x < count($key); $x++) //count() counts all elements in an array
|
||||
{
|
||||
// Sanitizes keys so only alphavalues are allowed
|
||||
if(!is_int($key[$x]))
|
||||
{
|
||||
if(mysql_num_rows($query) > 1)
|
||||
$this->result[$i][$key[$x]] = $r[$key[$x]];
|
||||
else if(mysql_num_rows($query) < 1)
|
||||
$this->result = null;
|
||||
else
|
||||
$this->result[$key[$x]] = $r[$key[$x]];
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
//return $query;
|
||||
}else{
|
||||
echo "Ada kesalahan pada query";
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
echo "Table tidak ditemukan";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function selectwithpaging($table, $limit = null, $hal = null,$where = null){
|
||||
$rows = '*';
|
||||
$q = 'SELECT '.$rows.' FROM '.$table;
|
||||
if($where != null) $q .= ' WHERE '.$where;
|
||||
|
||||
if (!empty($hal)) {
|
||||
$page = $hal - 1;
|
||||
$MulaiAwal = $limit * $page;
|
||||
} else if (!empty($hal) and $hal == 1) {
|
||||
$MulaiAwal = 0;
|
||||
} else if (empty($hal)) {
|
||||
$MulaiAwal = 0;
|
||||
}
|
||||
$q .= ' LIMIT '.$MulaiAwal.' , '.$limit;
|
||||
if($this->tableExists($table)){
|
||||
$query = @mysql_query($q);
|
||||
if($query){
|
||||
|
||||
$this->numRows = mysql_num_rows($query); //retrieves the number of rows from the query
|
||||
for($i = 0; $i < $this->numRows; $i++)
|
||||
{
|
||||
$r = mysql_fetch_array($query); //mysql_fetch_array returns an array that corresponds to the fetched row
|
||||
$key = array_keys($r); //array_keys() returns the keys, numeric and string, from the input array.
|
||||
for($x = 0; $x < count($key); $x++) //count() counts all elements in an array
|
||||
{
|
||||
// Sanitizes keys so only alphavalues are allowed
|
||||
if(!is_int($key[$x]))
|
||||
{
|
||||
if(mysql_num_rows($query) > 1)
|
||||
$this->result[$i][$key[$x]] = $r[$key[$x]];
|
||||
else if(mysql_num_rows($query) < 1)
|
||||
$this->result = null;
|
||||
else
|
||||
$this->result[$key[$x]] = $r[$key[$x]];
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
//return $query;
|
||||
}else{
|
||||
echo "Ada kesalahan pada query";
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
echo "Table tidak ditemukan";
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function insert($table,$values,$rows = null) {
|
||||
if($this->tableExists($table)){
|
||||
$insert = 'INSERT INTO '.$table;
|
||||
if($rows != null)$insert .= ' ('.$rows.')';
|
||||
for($i = 0; $i < count($values); $i++){
|
||||
if(is_string($values[$i]))$values[$i] = '"'.$values[$i].'"';
|
||||
}
|
||||
$values = implode(',',$values);
|
||||
$insert .= ' VALUES ('.$values.')';
|
||||
echo $insert;
|
||||
$insert_query = @mysql_query($insert);
|
||||
if($insert_query){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($table,$where = null){
|
||||
if($this->tableExists($table)){
|
||||
if($where == null){
|
||||
$delete = 'DELETE '.$table;
|
||||
}else{
|
||||
$delete = 'DELETE FROM '.$table.' WHERE '.$where; //equivalent to DELETE FROM table1 WHERE ......
|
||||
}
|
||||
$delete = @mysql_query($delete);
|
||||
if($delete){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function update($table,$rows,$where){
|
||||
if($this->tableExists($table)){
|
||||
/*
|
||||
for($i = 0; $i < count($where); $i++){
|
||||
if($i%2 != 0){
|
||||
if(is_string($where[$i])){
|
||||
if(($i+1) != null)$where[$i] = '"'.$where[$i].'" AND ';
|
||||
else $where[$i] = '"'.$where[$i].'"';
|
||||
}
|
||||
}
|
||||
}
|
||||
$where = implode('',$where);
|
||||
*/
|
||||
$update = 'UPDATE '.$table.' SET ';
|
||||
$keys = array_keys($rows);
|
||||
for($i = 0; $i < count($rows); $i++){
|
||||
if(is_string($rows[$keys[$i]])) $update .= $keys[$i].'="'.$rows[$keys[$i]].'"';
|
||||
else $update .= $keys[$i].'='.$rows[$keys[$i]];
|
||||
// add commas
|
||||
if($i != count($rows)-1) $update .= ',';
|
||||
}
|
||||
$update .= ' WHERE '.$where;
|
||||
//echo $update;
|
||||
$query = @mysql_query($update);
|
||||
if($query)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getResult(){
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
private function tableExists($table){
|
||||
$tableInDb = @mysql_query('SHOW TABLES FROM '.$this->db_name.' LIKE "'.$table.'"');
|
||||
if($tableInDb)
|
||||
{
|
||||
if(mysql_num_rows($tableInDb)==1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,149 @@
|
||||
<!doctype html>
|
||||
<?php
|
||||
include('database.php');
|
||||
include('mahasiswa.php');
|
||||
$mhs = new Mahasiswa();
|
||||
$mhs->connect();
|
||||
if(!isset($_POST['submit'])){
|
||||
if (isset($_GET['id'])){
|
||||
$car = $_GET['id'];
|
||||
$action='update&id='.$_GET['id'].'';
|
||||
$mhs->select('mahasiswa','*',"nim='$car'");
|
||||
$res = $mhs->getResult();
|
||||
}else{
|
||||
$action='insert';
|
||||
}
|
||||
}
|
||||
else{
|
||||
if ($_GET['action']=='update'){
|
||||
$id = $_GET['id'];
|
||||
$nim = $_POST['nim'];
|
||||
$nama = $_POST['nama'];
|
||||
$telp = $_POST['telp'];
|
||||
$asal = $_POST['asal'];
|
||||
$alamat = $_POST['alamat'];
|
||||
if(!empty($_FILES['file']['name'])){
|
||||
$photos = $mhs->foto($_FILES,$id,'update',$nim);
|
||||
$foto = $foto['lokasi'];
|
||||
}
|
||||
else{
|
||||
$foto = $mhs->renamefoto($id,$nim);
|
||||
}
|
||||
$rows=array(
|
||||
'nim' => $nim,
|
||||
'nama' => $nama,
|
||||
'telp' => $telp,
|
||||
'asal' => $asal,
|
||||
'alamat'=> $alamat,
|
||||
'foto' => $foto
|
||||
);
|
||||
if($mhs->update('mahasiswa',$rows,'nim = '.$_GET['id'].'')){
|
||||
header('Location: index.php');
|
||||
}else{
|
||||
echo 'Tidak bisa input';
|
||||
}
|
||||
}
|
||||
else{
|
||||
$nim = $_POST['nim'];
|
||||
$nama = $_POST['nama'];
|
||||
$telp = $_POST['telp'];
|
||||
$asal = $_POST['asal'];
|
||||
$alamat = $_POST['alamat'];
|
||||
if(!empty($_FILES['file']['name'])){
|
||||
$foto = $mhs->foto($_FILES,$nim,'insert',$nim);
|
||||
$lokasi = $foto['lokasi'];
|
||||
$values=array($nim,$nama,$telp,$asal,$alamat,$lokasi);
|
||||
$rows = null;
|
||||
}else{
|
||||
$values=array($nim,$nama,$telp,$asal,$alamat);
|
||||
$rows= "nim,nama,telp,asal,alamat";
|
||||
}
|
||||
if($mhs->insert('mahasiswa',$values,$rows)){
|
||||
header('Location: index.php');
|
||||
}else{
|
||||
echo 'Tidak bisa input';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Document</title>
|
||||
<link href="style.css" rel="stylesheet">
|
||||
<link href="bootstrap.min.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>Registrasi</h1>
|
||||
</div>
|
||||
<form method="post" action="?action=<?php echo $action ?>" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<legend>Data</legend>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="300px">Nama</td>
|
||||
<td width="30px">:</td>
|
||||
<td><input type="text" name="nama" value="<?php if (isset($_GET['id'])) echo $res['nama']; ?>" maxlength="30" required></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>NIM</td>
|
||||
<td>:</td>
|
||||
<td><input type="text" name="nim" value="<?php if (isset($_GET['id'])) echo $res['nim']; ?>" onkeypress="return isNumberKey(event)" maxlength="12" required></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Alamat</td>
|
||||
<td>:</td>
|
||||
<td><input type="text" name="alamat" value="<?php if (isset($_GET['id'])) echo $res['alamat']; ?>" maxlength="50" required></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Telp</td>
|
||||
<td>:</td>
|
||||
<td><input type="text" name="telp" value="<?php if (isset($_GET['id'])) echo $res['telp']; ?>" onkeypress="return isNumberKey(event)" maxlength="20" required></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sekolah Asal</td>
|
||||
<td>:</td>
|
||||
<td><input type="text" name="asal" value="<?php if (isset($_GET['id'])) echo $res['asal']; ?>" maxlength="20" required></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Photo</td>
|
||||
<td>:</td>
|
||||
<td style="text-align:center">
|
||||
<?php if (!empty($res['foto'])){
|
||||
?>
|
||||
<div style="background-color:#f0f0f0;padding:10px;">
|
||||
<img src="<?php echo $res['foto'] ?>" height="200" width="300" name="foto"></img></br>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<br/><input type="file" name="file" id="inputfile" style>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<div style="text-align:center;margin:20px;">
|
||||
<a href="index.php"><button type="button" class="btn"><i class=" icon-ban-circle"></i> Cancel</button></a>
|
||||
<button type="submit" name="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
function isNumberKey(evt)
|
||||
{
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode
|
||||
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
||||
{
|
||||
alert('Number Only');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
</script>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
include('database.php');
|
||||
include('mahasiswa.php');
|
||||
$mhs = new Mahasiswa();
|
||||
$mhs->connect();
|
||||
if (isset($_GET['id'])){
|
||||
$mhs->deletemhs($_GET['id']);
|
||||
}
|
||||
$page = null;
|
||||
$search = null;
|
||||
//cek apakah ada getPage
|
||||
if (isset($_GET['page']))$page = $_GET['page'];
|
||||
//cek apakah ada getSearch
|
||||
if ((isset($_GET['search'])) && (($_GET['search'])!='')){
|
||||
$search = $_GET['search'];
|
||||
$mhs->select('mahasiswa','*',"nama LIKE '%$search%' or nim LIKE '%$search%'");
|
||||
}
|
||||
else{
|
||||
$mhs->select('mahasiswa');
|
||||
}
|
||||
$res = $mhs->getResult();
|
||||
//pagination
|
||||
if (!array_key_exists(0, $res)){
|
||||
$resu[0]=$res;
|
||||
$result = $mhs->paging($resu,5,$page,$search);
|
||||
}
|
||||
else{
|
||||
$result = $mhs->paging($res,5,$page,$search);
|
||||
}
|
||||
?>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Document</title>
|
||||
<link href="style.css" rel="stylesheet">
|
||||
<link href="bootstrap.min.css" rel="stylesheet">
|
||||
<script>
|
||||
function delconfirm(id){
|
||||
var del=confirm('Are you sure you want to delete '+id+' record?');
|
||||
if (del==true) window.location.href = 'index.php?id='+id;
|
||||
else window.location.href = 'index.php';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin-top:50px;">
|
||||
<div class="page-header">
|
||||
<h1>Data Mahasiswa</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="navbar span11">
|
||||
<div class="navbar-inner">
|
||||
<form class="navbar-search pull-left" method="get" action="index.php">
|
||||
<div class="input-append">
|
||||
<input type="text" class="span2" name="search" placeholder="Search..." value="<?php if (isset($_GET['search'])) echo $_GET['search']; ?>">
|
||||
<a href="index.php"><button type="button" class="btn btn-small"><i class="icon-remove"></i></button></a>
|
||||
</div>
|
||||
</form>
|
||||
<a href="form.php"><button class="btn btn-small btn-primary pull-right" style="margin-top:8px;">+ Tambah</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row"><div class="span11">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<th style="width:100px">NIM</th>
|
||||
<th style="width:100px">Nama</th>
|
||||
<th style="width:200px">Alamat</th>
|
||||
<th style="width:130px">Telp</th>
|
||||
<th style="width:200px">Sekolah Asal</th>
|
||||
<th style="width:50px">Action</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$i=$result['mulai'];
|
||||
if( !empty( $result['data'] ) ){
|
||||
foreach ($result['data'] as $value) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $result['data'][$i]['nim'] ?></td>
|
||||
<td><?php echo $result['data'][$i]['nama'] ?></td>
|
||||
<td><?php echo $result['data'][$i]['alamat'] ?></td>
|
||||
<td><?php echo $result['data'][$i]['telp'] ?></td>
|
||||
<td><?php echo $result['data'][$i]['asal'] ?></td>
|
||||
<td>
|
||||
<a href="<?php echo 'view.php?id='.$result['data'][$i]['nim'] ?>"><i class="icon-eye-open" title="View"></i></a>
|
||||
<a href="<?php echo 'form.php?id='.$result['data'][$i]['nim'] ?>"><i class="icon-edit" title="Edit"></i></a>
|
||||
<i class="icon-trash" title="Delete" onclick="delconfirm(<?php echo $result['data'][$i]['nim'] ?>)"></i>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div></div>
|
||||
<?php
|
||||
echo $result['paging'];
|
||||
$mhs->disconnect();
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
class Mahasiswa extends Database{
|
||||
private $nama;
|
||||
private $nim;
|
||||
private $telp;
|
||||
private $alamat;
|
||||
private $asal;
|
||||
private $pagination;
|
||||
|
||||
public function paging($data,$Batas,$hal = 1,$cari = null){
|
||||
//print_r($this->result);
|
||||
if (!empty($hal)) {
|
||||
$page = $hal - 1;
|
||||
$MulaiAwal = $Batas * $page;
|
||||
} else if (!empty($hal) and $hal == 1) {
|
||||
$MulaiAwal = 0;
|
||||
} else if (empty($hal)) {
|
||||
$MulaiAwal = 0;
|
||||
}
|
||||
for ($i = $MulaiAwal; $i < $MulaiAwal+$Batas; $i++) {
|
||||
if (array_key_exists($i, $data)){
|
||||
$new[$i] = $data[$i];
|
||||
}
|
||||
}
|
||||
$pagination = "";
|
||||
$jumlahData = sizeof($data);
|
||||
//echo "</br>".$jumlahData." Hasil";
|
||||
if ($jumlahData > $Batas) {
|
||||
$pagination = $pagination.'<div class="pagination" style="font-size:10pt;"><ul>';
|
||||
$c = ceil($jumlahData / $Batas);
|
||||
for ($i = 1; $i <= $c; $i++) {
|
||||
$pagination = $pagination.'<li ';
|
||||
if ($hal == $i) {
|
||||
$pagination = $pagination.'class="active"';
|
||||
}
|
||||
$pagination = $pagination."><a href=?";
|
||||
if(isset($cari))$pagination = $pagination."search=".$cari;
|
||||
$pagination = $pagination."&page=".$i.">".$i."</a></li>";
|
||||
}
|
||||
$pagination = $pagination.'</ul></div>';
|
||||
}
|
||||
|
||||
$hasil = array(
|
||||
"paging" => $pagination,
|
||||
"data" => $new,
|
||||
"mulai" => $MulaiAwal,
|
||||
);
|
||||
return $hasil;
|
||||
}
|
||||
|
||||
public function getPaging($array){
|
||||
return $this->pagination;
|
||||
}
|
||||
|
||||
public function foto($file,$id = null,$aksi,$newid){
|
||||
$allowedExts = array("gif", "jpeg", "jpg", "png");
|
||||
$temp = explode(".", $file["file"]["name"]);
|
||||
$extension = end($temp);
|
||||
if ((($file["file"]["type"] == "image/gif")
|
||||
|| ($file["file"]["type"] == "image/jpeg")
|
||||
|| ($file["file"]["type"] == "image/jpg")
|
||||
|| ($file["file"]["type"] == "image/pjpeg")
|
||||
|| ($file["file"]["type"] == "image/x-png")
|
||||
|| ($file["file"]["type"] == "image/png"))
|
||||
&& ($file["file"]["size"] < 2000000)
|
||||
&& in_array($extension, $allowedExts))
|
||||
{
|
||||
if ($file["file"]["error"] > 0)
|
||||
{
|
||||
echo "Return Code: " . $file["file"]["error"] . "<br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((file_exists("upload/" . $id.".".$extension)) && $aksi == 'insert')
|
||||
{
|
||||
echo 'aksi : insert dan file sudah ada </br>';
|
||||
echo $id . " already exists. ";
|
||||
$hasil = array(
|
||||
'bool' => false
|
||||
);
|
||||
}
|
||||
else if ((file_exists("upload/" . $id.".".$extension)) && $aksi == 'update')
|
||||
{
|
||||
echo 'aksi : update dan file sudah ada';
|
||||
unlink("upload/" . $id.".".$extension);
|
||||
move_uploaded_file($file["file"]["tmp_name"],
|
||||
"upload/" . $newid.".".$extension);
|
||||
$hasil = array(
|
||||
'lokasi' => "upload/" . $newid.".".$extension,
|
||||
'bool' => true
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'aksi : insert/update tapi file belum ada';
|
||||
move_uploaded_file($file["file"]["tmp_name"],
|
||||
"upload/" . $newid.".".$extension);
|
||||
$hasil = array(
|
||||
'lokasi' => "upload/" . $newid.".".$extension,
|
||||
'bool' => true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$hasil = array(
|
||||
'bool' => false
|
||||
);
|
||||
}
|
||||
return $hasil;
|
||||
}
|
||||
|
||||
public function deletemhs($id){
|
||||
if($this->delete('mahasiswa','nim = '.$id.'')){
|
||||
$files = glob("upload/$id.*");
|
||||
foreach ($files as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
header('Location: index.php');
|
||||
}
|
||||
else echo 'Gagal hapus '.$id.'.*';
|
||||
}
|
||||
|
||||
public function renamefoto($id,$newid){
|
||||
$this->select('mahasiswa', 'foto', "nim='$id'");
|
||||
$res = $this->getResult();
|
||||
$file = $res['foto'];
|
||||
$path_parts = pathinfo($file);
|
||||
//echo $path_parts['dirname'], "\n";
|
||||
//echo $path_parts['basename'], "\n";
|
||||
//echo $path_parts['extension'], "\n";
|
||||
//echo $path_parts['filename'], "\n";
|
||||
rename ('upload/'.$id.'.'.$path_parts['extension'], 'upload/'.$newid.'.'.$path_parts['extension']);
|
||||
$newfile = 'upload/'.$newid.'.'.$path_parts['extension'];
|
||||
return $newfile;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,68 @@
|
||||
<!doctype html>
|
||||
<?php
|
||||
include('database.php');
|
||||
include('mahasiswa.php');
|
||||
$mhs = new Mahasiswa();
|
||||
$mhs->connect();
|
||||
$car = $_GET['id'];
|
||||
$mhs->select('mahasiswa','*',"nim='$car'");
|
||||
$res = $mhs->getResult();
|
||||
?>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Document</title>
|
||||
<link href="style.css" rel="stylesheet">
|
||||
<link href="bootstrap.min.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
body{
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
.container{
|
||||
margin:100px;
|
||||
background-color: #fff;
|
||||
box-shadow:0 1px 3px rgba(0,0,0,.5);
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>Informasi</h1>
|
||||
</div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td rowspan="5" width="200"><img src="<?php if (!empty($res['foto'])) echo $res['foto']; else echo 'upload/nophoto.jpg'; ?>" width="200" height="300"/></td>
|
||||
<td width="100">Nama</td>
|
||||
<td width="10">:</td>
|
||||
<td><?php echo $res['nama']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>NIM</td>
|
||||
<td>:</td>
|
||||
<td><?php echo $res['nim']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Alamat</td>
|
||||
<td>:</td>
|
||||
<td><?php echo $res['alamat']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Telp</td>
|
||||
<td>:</td>
|
||||
<td><?php echo $res['telp']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sekolah Asal</td>
|
||||
<td>:</td>
|
||||
<td><?php echo $res['asal']; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="text-align:center;">
|
||||
<a href="index.php"><button class="btn"><i class="icon-arrow-left"></i> Back</button></a>
|
||||
<a href="<?php echo 'form.php?id='.$res['nim'] ?>"><button class="btn"><i class="icon-edit"></i> Update</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user