You are on page 1of 1

Index.

php
Koneksi.php
Createtable.php
<!DOCTYPE html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD
PUBLIC "-//W3C//DTD XHTML 1.0
1.0 Transitional//EN"
HTML 4.0 Transitional//EN">
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1<html
"http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd">
xmlns="http://www.w3.org/1999/xhtml"
transitional.dtd">
<html
xml:lang="en" lang="en">
<html
<head>
xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Menciptakan Tabel</title>
xml:lang="en"
<meta http-equiv="Content-Type"
</head>
lang="en">
content="text/html; charset=utf-8" /> <body>
<head>
<title>Untitled Document</title>
<?php
<title>Akses dan Manipulasi Data</title>
</head>
require_once './koneksi.php';
<style type="text/css">
<body>
$sql = 'CREATE TABLE mahasiswa (
.even {
<?php
nim VARCHAR(12) NOT NULL,
background: #ddd;
// Catatan:
nama VARCHAR(40) NOT NULL,
}
//
Jika
perlu,
sesuaikan
nama
user
dan
alamat VARCHAR(100),
</style>
password
PRIMARY KEY (nim)
</head>
$host = 'localhost';
) ENGINE=MyISAM;';
<body>
$user = 'root';
$res = mysql_query($sql);
<?php
$pass = '1q2w3e4r5t';
if ($res) {
ini_set('display_errors',1);
$db
=
'akucucok';
echo 'Tabel Created';
// Meng-include file koneksi dan data
$cnn = mysql_connect($host, $user, $pass); mysql_close($res);
handler
if (!$cnn) {
} else {
require_once './koneksi.php';
exit('Koneksi
Gagal');
echo mysql_error();
require_once './data_handler.php';
}
}
// Konstanta nama tabel
$db = mysql_select_db($db);
?>
define('MHS', 'mahasiswa');
if (!$db) {
// Memanggil fungsi data handler
exit('Gagal Memilih Database');
</body>
data_handler('?m=data');
}
</html>
?>
?>
</body>
</html>
</td>
</body>
<td>
tambahdata.php
</html>
<?php echo $row[0];?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD
</td>
//
Tambahkan
data
baru
ke
tabel
HTML 4.0 Transitional//EN">
<td>
$sql
=
"INSERT
INTO
mahasiswa
<html
<?php echo $row[1];?>
VALUES ('" .$nim. "', '" .$nama. "', '" .
xmlns="http://www.w3.org/1999/xhtml"
</td>
$alamat. "' )";
<td>
xml:lang="en" lang="en">
$res = mysql_query($sql);
<?php echo $row[2];?>
<head>
</td>
if ($res) {
<title>Tambah Data</title>
</tr>
echo 'Data Berhasil Ditambahkan';
</head>
<?php
mysql_close($res);
<body>
$i++;
} else {
<form action="<?php
}
echo
'Gagal
Menambah
Data
<br
/>';
$_SERVER['PHP_SELF'];?>"
?>
echo mysql_error();
method="post">
</table>
}
<?php
<table>
}
} else {
<tr>
echo 'Data Tidak Ditemukan';
echo
'<hr
/>';
<td>NIM</td>
}
// Memanfaatkan script pengambilan
<td><input type="text" name="nim"
mysql_close($res);
data
untuk
/></td>
}
// menampilkan hasil
</tr>
?>
require_once
'./seleksi.php';
<tr>
?>
<td>Nama</td>
</body>
<td><input type="text" name="nama"<head>
<link rel="stylesheet"
size=40 /></td>
Seleksi.php
href="css/bootstrap.css"/>
</tr>
<?php
<link rel="stylesheet"
// File: seleksi.php
<tr>
href="css/style.css"/>
<td>Alamat</td>
</head>
require_once './koneksi.php';
<body>
<td><input type="text" name="alamat"
<div id="box">
size=60 /></td>
$sql class="table
= 'SELECT * FROM
mahasiswa';
<table
table-bordered">
</tr>
$res = mysql_query($sql);
<caption>No</caption>
<tr>
if ($res) {
<li<li
class="active"><a
<thead>
<td><input type="submit"
if (mysql_num_rows($res)) { ?>
href="#">Home</a></li
<tr>
class="active"><a
>
value="Simpan" /></td>
<table border=1 cellspacing=1
<th>1</th>
href="#">Home</a>
cellpadding=5>
</tr>
<th>2</th>
</li>
<li><a
<tr>
</tr>
</table>
href="#">Link</a></li>
<th>#</th>
</thead>
<li><a
</form>
<th width=100>NIM</th>
<tbody>
href="#">Link</a></
<li><a
<?php
<th width=150>Nama</th>
href="#">Link</a></li>
<tr>
li>
require_once './koneksi.php';
<th>Alamat</th>
<td>Nama</td>
// Jika field nim dan nama diisi lalu
</ul></div>
</tr>
<li><a
<td>Nim</td>
disubmit
<?php
href="#">Link</a></
</tr>
if (isset($_POST['nim']) &&
$i = 1;
li>
</tbody>
while ($row = mysql_fetch_row($res))
isset($_POST['nama'])) {
</table>
?>
<div{class="navbar
navbar-inverse navbar$nim = $_POST['nim'];
<tr>
fixed-top">
$nama = $_POST['nama'];
<td>
<div
class="navbar-inner">
$alamat = $_POST['alamat'];
<?php
echo $i;?>
<div
class="container">

You might also like