Tugas Membuat Data Buku (Web Design)

1. Membuat database
Contoh : ade_11080965

2. Membuat tabel
Contoh : tb_buku

Isi field seperti gambar dibawah ini :



3. Buat design untuk input data buku seperti gambar dibawah ini :



Listing input data buku :

<body>
<form id="form1" name="form1" method="post" action="save_data_buku.php">
<table width="545" border="0">
<tr>
<td width="284">kodebuku</td>
<td width="26">:</td>
<td width="221"><label>
<input name="kode" type="text" id="kode" />
</label></td>
</tr>
<tr>
<td>judul</td>
<td>:</td>
<td><label>
<input name="judul" type="text" id="judul" />
</label></td>
</tr>
<tr>
<td>jenis</td>
<td>:</td>
<td><label>
<select name="jenis" id="jenis">
<option>Jaringan</option>
<option>Web Programming</option>
<option>Java</option>
</select>
</label></td>
</tr>
<tr>
<td>pengarang</td>
<td>:</td>
<td><label>
<input name="pengarang" type="text" id="pengarang" />
</label></td>
</tr>
<tr>
<td>penerbit</td>
<td>:</td>
<td><label>
<input name="penerbit" type="text" id="penerbit" />
</label></td>
</tr>
<tr>
<td>sinopsis</td>
<td>:</td>
<td><label>
<textarea name="sinopsis" id="sinopsis"></textarea>
</label></td>
</tr>
</table>
<p>
<label>
<input name="submit" type="submit" id="submit" value="kirim" />
</label>
<label>
<input name="reset" type="reset" id="reset" value="cancel" />
</label>
</p>
</form>
</body>


4. Buat koneksi ke database

Listing koneksi :

<?php
$host='localhost';
$user='root';
$pass='password';
$db='ade_11080965';
$ok=mysql_connect($host,$user,$pass) or die ('gagal konek'.mysql_error());
mysql_select_db($db,$ok);
?>


5. Buat Perintah SQL untuk penyimpanan ke database

Listing :

<?
include "koneksi.php";

$kodebuku= $_POST["kode"];
$judul= $_POST["judul"];
$jenis= $_POST["jenis"];
$pengarang= $_POST["pengarang"];
$penerbit= $_POST["penerbit"];
$sinopsis= $_POST["sinopsis"];
$input ="insert into data_buku(kodebuku,judul,jenis,pengarang,penerbit,sinopsis)values('$kodebuku','$judul','$jenis','$pengarang','$penerbit','$sinopsis')";
$query = mysql_query($input);
if (query)
{
echo"<pre>kodebuku:$kodebuku</pre>";
echo"<pre>judul:$judul</pre>";
echo"<pre>jenis:$jenis</pre>";
echo"<pre>pengarang:$pengarang</pre>";
echo"<pre>penerbit:$penerbit</pre>";
echo"<pre>sinopsis:$sinopsis</pre>";
echo "data di atas telah disimpan<br>";
echo "<a href= 'data_buku.php'>back</a>";
echo "atau ";
echo "<a href=' view_databuku.php'> Lihat Tampilan</a>";
}

else
{echo "gagal tersimpan";
echo "<a href=' data_buku.php'>lihat data</a>";

}
?>


6. Buat design untuk menampilkan tb_buku ke tabel seperti dibawah ini :


<table width="880" border="4" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFF99">
<tr>
<td width="104"><div align="center"><strong>no</strong></div></td>
<td width="86"><div align="center"><strong>kode buku</strong> </div></td>
<td width="115"><div align="center"><strong>judul</strong></div></td>
<td width="72"><div align="center"><strong>jenis</strong></div></td>
<td width="108"><div align="center"><strong>pengarang</strong></div></td>
<td width="103"><div align="center"><strong>penerbit</strong></div></td>
<td width="262"><div align="center"><strong>sinopsis</strong></div></td>
</tr>
<?php
include "koneksi.php";

$perintah="select * from data_buku"; // $ perintah Berguna sebagai variabel penampung //
$hasil=mysql_query($perintah);
while ($row=mysql_fetch_array($hasil))
{
$no++;
?>
<tr>
<td><div align="center"><?php echo $no; ?></div></td>
<td><div align="center"><?php echo $row['kodebuku'];?></div></td>
<td><div align="center"><?php echo $row['judul'];?></div></td>
<td><div align="center"><?php echo $row['jenis'];?></div></td>
<td><div align="center"><?php echo $row['pengarang'];?></div></td>
<td><div align="center"><?php echo $row['penerbit'];?></div></td>
<td><div align="center"><?php echo $row['sinopsis'];?></div></td>
</tr>
<?php } ?>
</table>


Selesai.. ^_^

Subscribe to receive free email updates:

1 Response to "Tugas Membuat Data Buku (Web Design)"

Berkomentarlah dengan Baik dan Sopan..