Men, ane punya script function bikin sendiri kek gini :
nama file : function.php
Spoiler for :
<?php
include 'inc/config.php';
$nim = $_POST['nim'];
$nama= $_POST['nama'];
function show() {
$query = "SELECT * FROM mhs";
$result=mysql_query($query) or die(mysql_error());
return $result;
}
function insert() {
$query = "INSERT INTO mhs (nim,nama)
VALUES ('$nim','$nama')";
$result=mysql_query($query) or die(mysql_error());
return $result;
}
function update() {
$query = "UPDATE mhs SET
nama='$nama'
WHERE nim='$nim'";
$result=mysql_query($query) or die(mysql_error());
return $result;
}
function delete() {
$query = "DELETE FROM mhs WHERE nim='$nim'";
$result=mysql_query($query) or die(mysql_error());
return $result;
}
?>
Trus ane mau nampilin data tersebut ke file ini :
nama file : index.php
Spoiler for :
<!DOCTYPE html>
<html lang='en'>
<meta charset='utf-8'>
<title>Iwan Kiashop</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta name='description' content=''>
<meta name='author' content=''>
<!-- Le styles -->
<style type='text/css'>
body {
padding-top: 60px;
padding-bottom: 40px;
background: url('assets/img/grey.png') repeat;
}
.atas {
padding-top: 9px;
}
</style>
<link href='assets/css/bootstrap.css' rel='stylesheet'>
<link href='assets/css/bootstrap-responsive.css' rel='stylesheet'>
<link href='assets/css/docs.css' rel='stylesheet'>
[removed][removed]
[removed][removed]
<link href='assets/img/favicon.png' rel='shortcut icon' />
<!-- MENAMBAHKAN NIVO SLIDER -->
<link rel='stylesheet' href='assets/css/default.css' type='text/css' media='screen' />
<link rel='stylesheet' href='assets/css/nivo-slider.css' type='text/css' media='screen' />
[removed][removed]
[removed]
$(window).load(function() {
$('#slider').nivoSlider();
});
[removed]
<body>
<div class='container'>
<legend>
Data Mahasiswa :
</legend>
<table class='table table-bordered'>
<thead>
<tr>
<th>NIM</th>
<th>Nama</th>
</tr>
</thead>
<?php
include 'inc/config.php';
require_once 'function.php';
show();
while ($rows=mysql_fetch_object(show())) {
?>
<tbody>
<tr>
<td><?php echo $rows -> nim;?></td>
<td><?php echo $rows -> nama;}?></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Tapi kok datanya malah gak nongol ya ?