Membuat tabel nilaiwebka2018 dengan menggunakan PHP my Admin
1. view.php
<?php
$host = "localhost"; // alamat atau host
$user = "root"; // username
$pass = ""; // password
$koneksi = mysql_connect("$host","$user",$pass);
mysql_select_db("nilaikar2018",$koneksi);
$query = mysql_query("select * from web",$koneksi);
$jumlah = mysql_num_rows($query);
echo "<center><b>Daftar Mahasiswa Pemrograman WEB</b>";
echo "<br><br>Jumlah Mahasiswa : $jumlah Orang";
echo("<table border=1>");
echo("<tr> <th>NIM</th> <th>Nama</th> <th>Absen</th> <th>Tugas</th> <th>UTS</th> <th>UAS</th> </tr>");
while($baris = mysql_fetch_array($query))
{
echo "<tr><td> $baris[0]</td>";
echo "<td> $baris[1]</td>";
echo "<td> $baris[2]</td>";
echo "<td> $baris[3]</td>";
echo "<td> $baris[4]</td>";
echo "<td> $baris[5]</td></tr>";
}
?>
2. inputnilai.html
<html> <head> </head> <body>
<form method="POST" action="inputnilai.php">
<pre>
NIM <input type="text" name="nim">
Nama <input type="text" name="nama">
Absen <input type="text" name="absen">
Tugas <input type="text" name="tugas">
UTS <input type="text" name="uts">
UAS <input type="text" name="uas">
<br>
<input type="submit" name="submit" value="Simpan">
<input type="reset" name="reset" value="Batal">
</pre>
</form> </body> </html>
<p align="center"><a href="view.php">View Data Mahasiswa</a></p>
3. inputnilai.php
<?php
$koneksi = mysql_connect("localhost","root","");
mysql_select_db("nilaikar2018", $koneksi);
mysql_query("insert into web (nim,nama,absen,tugas,uts,uas)
values ('$_POST[nim]','$_POST[nama]','$_POST[absen]','$_POST[tugas]','$_POST[uts]','$_POST[uas]')",$koneksi);
echo "Data telah dimasukkan";
?>
<p align="center"><a href="view.php">View Data Mahasiswa</a></p>
4. Viewedit.php
<?php
$host = "localhost"; // alamat atau host
$user = "root"; // username
$pass = ""; // password
$koneksi = mysql_connect("$host","$user",$pass);
mysql_select_db("nilaiwebka2018",$koneksi);
$query = mysql_query("select*from web",$koneksi);
$jumlah = mysql_num_rows($query);
echo "<center><b>Daftar Mahasiswa Pemograman WEB</b>";
echo "<br><br>Jumlah Mahasiswa : $jumlah Orang<br><br>";
echo("<table border=5>");
echo("<tr> <th>NIM</th> <th>Nama</th> <th>Absen</th> <th>Tugas</th> <th>UTS</th> <th>UAS</th> </tr>");
while($baris = mysql_fetch_array($query))
{
echo "<tr align=center>><td> $baris[0]</td>";
echo "<td> $baris[1] </td>";
echo "<td> $baris[2] </td>";
echo "<td> $baris[3] </td>";
echo "<td> $baris[4] </td>";
echo "<td> $baris[5] </td>";
echo "<td> <a href=editnilai.php?nim=$baris[0]> Edit </a> </tr>";
}
?>
5. editnilai.php
<?php
$koneksi=mysql_connect("localhost","root","");
mysql_select_db("nilaiwebka2018",$koneksi);
$query = mysql_query("select * from web where NIM='$_GET[nim]'",$koneksi);
while ($baris=mysql_fetch_array($query))
{
echo"<form method=\"post\"action=\"updatenilai.php\">";
echo"<br>NIM <input type=\"text\"name=\"nim\"value=\"$baris[0]\">";
echo"<br>Nama <input type=\"text\"name=\"nama\"value=\"$baris[1]\">";
echo"<br>Absen <input type=\"text\"name=\"Absen\"value=\"$baris[2]\">";
echo"<br>Tugas <input type=\"text\"name=\"Tugas\"value=\"$baris[3]\">";
echo"<br>UTS <input type=\"text\"name=\"UTS\"value=\"$baris[4]\">";
echo"<br>UAS <input type=\"text\"name=\"UAS\"value=\"$baris[5]\">";
echo"<br><br>";
echo"<input type=\"submit\"name=\"submit\"value=\"update\">";
echo"</form>";
}
?>
6. updatenilai.php
<?php
$koneksi=mysql_connect("localhost","root","");
mysql_select_db("nilaiwebka2018",$koneksi);
$query=mysql_query("update web set NIM='$_POST[nim]',Nama='$_POST[nama]',absen='$_POST[Absen]',tugas='$_POST[Tugas]', uts='$_POST[UTS]',uas='$_POST[UAS]' where NIM='$_POST[nim]'");
echo "Data dengan NIM = '$_POST[nim]' telah di update";
?>
7. viewdelete.php
<?php
$host="localhost";
$user="root";
$pass="";
$koneksi=mysql_connect("$host","$user",$pass);
mysql_select_db("nilaiwebka2018",$koneksi);
$query=mysql_query("select*from web",$koneksi);
$jumlah=mysql_num_rows($query);
echo"<center><br><br><b>DAFTAR NILAI MAHASISWA MATA KULIAH PEMOGRAMAN WEB</b>";
echo"<br><br>Jumlah Mahasiswa : $jumlah Orang";
echo("<table border=5 width=50%>");
echo("<tr><th>NIM</th><th>Nama</th><th>Absen</th><th>Tugas</th><th>UTS</th><th>UAS</></tr>");
while($baris=mysql_fetch_array($query))
{
echo"<tr align=center><td>$baris[0]</td>";
echo"<td>$baris[1]</td>";
echo"<td>$baris[2]</td>";
echo"<td>$baris[3]</td>";
echo"<td>$baris[4]</td>";
echo"<td>$baris[5]</td>";
echo "<td> <a href=deletenilai.php?nim=$baris[0]> Hapus </a> </tr>";
}
?>
8. deletenilai.php
<?php
$koneksi=mysql_connect("localhost","root","");
mysql_select_db("nilaiwebka2018",$koneksi);
$query=mysql_query("delete from web where NIM='$_GET[nim]'",$koneksi);
echo "Data dengan NIM=$_GET[nim] telah dihapus";
?>
9. carinilai.html
<html><head>
<title>Pencarian Data Mahasiswa</title>
</head>
<body>
<center>
<form name method="post" action="carinilai.php">
<select name="kolom">
<option Value="NIM">NIM</option>
<option Value="Nama">Nama</option>
<option Value="Absen">Absen</option>
<option Value="Tugas">Tugas</option>
<option Value="UTS">UTS</option>
<option Value="UAS">UAS</option>
</select>
Masukkan kata yang anda cari <input type="text" name="cari">
<input type="submit" value="cari">
</form>
</center>
</body>
</html>
10. carinilai.php
<?PHP$koneksi=mysql_connect("localhost","root","");
mysql_select_db("nilaiwebka2018",$koneksi);
$query=mysql_query("select*from web where $_POST[kolom] like '%$_POST[cari]%'",$koneksi);
$jumlah=mysql_num_rows($query);
echo"<center>";
echo"<h2>Hasil Pencarian</h2>";
echo"Ditemukan : $jumlah Orang";
echo"<table border='1'cellpadding='3'cellspacing='5'>";
echo"
<tr bgcolor='pink'>
<td><b>NIM</td>
<td><b>Nama Mahasiswa</td>
<td><b>Absen</td>
<td><b>Tugas</td>
<td><b>UTS</td>
<td><b>UTS</td>
</tr>";
while($baris=mysql_fetch_array($query))
{
echo"<tr><td>$baris[0]</td>";
echo "<td> $baris[1] </td>";
echo "<td> $baris[2] </td>";
echo "<td> $baris[3] </td>";
echo "<td> $baris[4] </td>";
echo "<td> $baris[5] </td>";
}
?>
Komentar
Posting Komentar