<?php
$hostName = "localhost";
$userName = "root";
$passWord = "";
$dataBase = "db_profil";
mysql_connect($hostName,$userName,$passWord) or die('Koneksi Gagal');
mysql_select_db($dataBase) or die('Database tidak ditemukan');
?>
<tr>
<td> Prodi </td>
<td>:</td>
<td>
<select name="prodi">
<option value='$p1'>S1 Administrasi Negara</option>
<option value='$p2'>D3 administrasi Negara</option>
<option value='$p3'>S1 PPKN</option>
<option value='$p4'>S1 HUKUM</option>
<?php
include "koneksi.php";
$prodi = $_GET['prodi'];
$q = mysql_query("select * from tb_profil where prodi ='$_GET [prodi]'");
while ($data = mysql_fetch_array($q)){
if ($data[prodi] == 'S1 Admin. Negara'){
$p1 = 'selected';
}
elseif($data[prodi] == 'D3 Admin. Negara'){
$p2 = 'selected';
}
elseif($data[prodi] == 'S1 PPKn'){
$p3 = 'selected';
}
elseif($data[prodi] == 'S1 Ilmu Hukum'){
$p4 = 'selected';
}
else{
$p1 = '';
$p2 = '';
$p3 = '';
$p4 = '';
}
echo "
<option value='$p1'>S1 AN</option>
<option value='$p2'>D3 AN</option>
<option value='$p3'>S1 PPKN</option>
<option value='$p4'>S1 HUKUM</option>
";
}
?>
</select></td>
</tr>
CREATE TABLE IF NOT EXISTS `tb_profil` (
`email` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`cpwd` varchar(50) NOT NULL,
`nim` int(10) NOT NULL default '0',
`nama` varchar(50) NOT NULL,
`prodi` enum('s1an','d3an','s1ppkn','s1hukum') NOT NULL,
`dpa` varchar(50) NOT NULL,
`alamat` varchar(100) NOT NULL,
`sex` enum('Laki-Laki','Perempuan') NOT NULL,
`agama` enum('islam','kristen','katholik','hindu','buddha') NOT NULL,
`kontak` varchar(20) NOT NULL,
`tentang` varchar(100) NOT NULL,
`awalgabung` datetime NOT NULL,
PRIMARY KEY (`nim`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;