0% found this document useful (0 votes)
15 views4 pages

Web School Rev 1

1. Create a database named "n_schooldb" and a table named "t_siswa" to store student data. 2. Display the student data on a web page using PHP and MySQL. 3. Create pages for connecting to the database, viewing student data, adding new data, and saving new data to the database table.

Uploaded by

Ilham Rerol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Web School Rev 1

1. Create a database named "n_schooldb" and a table named "t_siswa" to store student data. 2. Display the student data on a web page using PHP and MySQL. 3. Create pages for connecting to the database, viewing student data, adding new data, and saving new data to the database table.

Uploaded by

Ilham Rerol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CRUD WEB SCHOOL

1. Buatlah database nama_schooldb;


2. Buat tabel dengan nama t_siswa dengan format dibawah ini dan isi sebanyak 5 data

3. Tampilkan data di halaman web menggunakan PHP dan Mysql

4. Buatlah halaman koneksinya


5. Buatlah halaman siswa.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Data Siswa</title>
</head>
<body>
<h1>DATA SISWA</h1>
<a href="input.php">INPUT DATA BARU</a>
<table border="1" width="80%">
<tr style="text-align:center; background:grey;color:white;">
<td>Nis</td><td>Nama</td><td>id_kelas</td><td>Status</td>
<td>Aksi</td>
</tr>
<?php
include "koneksi.php";
$sql = $koneksi->query("select * from t_siswa");
while ($data = $sql->fetch_assoc()){
$id_kelas = $data['id_kelas'];
?>
<tr>
<td><?=$data['nis']; ?></td><td><?=$data['nama']; ?></td>
<td>
<?php
if ($id_kelas=='1') { echo "XII TKJ 1";}
else if ($id_kelas=='2') { echo "XII TKJ 2";}
else if ($id_kelas=='3') { echo "XII AKL 1";}
else if ($id_kelas=='4') { echo "XII AKL 2";}
else { echo "Tidak Terdaftar";}
?>
</td>
<td><?=$data['status']; ?></td>
<td>
<a href="edit.php">Edit</a>
<a href="hapus.php">Hapus</a>
</td>
</tr>
<?php } ?>
</table>

</body>
</html>

6. Buat halaman input.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Input Data Siswa</title>
</head>
<body>
<h1>INPUT DATA SISWA</h1>
<a href="siswa.php">KEMBALI KE DATA SISWA</a>
<form action="simpan.php" method="post">
<table>
<tr>
<td>NIS</td><td><input type="text" name="nis"></td>
</tr>
<tr>
<td>Nama</td><td><input type="text" name="nama"></td>
</tr>
<tr>
<td> KELAS</td>
<td>
<select name="id_kelas" id="id_kelas">
<option value="1">XII TKJ 1</option>
<option value="2">XII TKJ 2</option>
<option value="3">XII AKL 1</option>
<option value="3">XII AKL 2</option>
</select>
</td>
</tr>
<tr>
<td>Status</td>
<td>
<select name="status" id="status">
<option value="aktif">Aktif</option>
<option value="tidakaktif">Tidak Aktif</option>
</select>
</td>
</tr>

</table>
<input type="submit" value="SIMPAN DATA BARU">
</form>
</body>
</html>

7. Buat halaman simpan.php

<?php
include "koneksi.php";
$nis =$_POST['nis'];
$nama =$_POST['nama'];
$id_kelas =$_POST['id_kelas'];
$status =$_POST['status'];

$perintah = "INSERT INTO t_siswa set


nis ='$nis',nama ='$nama',
id_kelas ='$id_kelas', status ='$status'
";

$eksekusi = mysqli_query($koneksi,$perintah) or die ("Gagal


query".mysqli_error());

echo "<meta http-equiv='refresh' content='0; url=siswa.php'>";


exit;
?>

You might also like