0% found this document useful (0 votes)
24 views2 pages

Charset: "Rudi" "Anto" "Joko" "Sinta" "Nama-Nama Mahasiswa: "

The document defines an associative array $fakultas that contains faculty names mapped to their program of study arrays. It then displays a form with a dropdown for selecting a faculty and another dependent dropdown for selecting a program of study. When a faculty is selected, it filters the second dropdown to only show relevant programs for that faculty. The selected values are displayed below the form.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Charset: "Rudi" "Anto" "Joko" "Sinta" "Nama-Nama Mahasiswa: "

The document defines an associative array $fakultas that contains faculty names mapped to their program of study arrays. It then displays a form with a dropdown for selecting a faculty and another dependent dropdown for selecting a program of study. When a faculty is selected, it filters the second dropdown to only show relevant programs for that faculty. The selected values are displayed below the form.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

<?

php
$fakultas = array(
"mipa" => array("matematika", "fisika", "kimia"),
"ilmu_komputer" => array("sistem_informasi", "teknik_informatika"),
"teknik" => array("elektro", "sipil", "industri")
);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>husnanlabs.blogspot.com</title>
</head>
<body>
<form name="frmFakultas" method="post" action="">
<table>
<tr>
<td><label for="selFakultas">Fakultas:</label></td>
<td><label for="selProdi">Program Studi:</label></td>
</tr>
<tr>
<td>
<select name="selFakultas"
onchange="document.frmFakultas.selProdi.selectedIndex=0;
document.frmFakultas.submit();">
<?php foreach ($fakultas as $fak => $prodi): ?>
<?php
if ($_POST["selFakultas"] == $fak) $selected1 = "selected";
else $selected1 = "";
?>
<option value="<?php echo $fak;?>" <?php echo $selected1; ?>>
<?php echo strtoupper($fak); ?>
</option>
<?php endforeach ?>
</select>
</td>
<td>
<select name="selProdi" onchange="document.frmFakultas.submit();">
<option value="---">---</option>
<?php foreach ($fakultas[$_POST["selFakultas"]] as $prodi): ?>
<?php
if ($_POST["selProdi"] == $prodi) $selected2 = "selected";
else $selected2 = "";
?>
<option value="<?php echo $prodi; ?>" <?php echo $selected2; ?>>
<?php echo strtoupper($prodi); ?>
</option>
<?php endforeach; ?>
</select>
</td>
</tr>
</table>
</form>
<p>Fakultas: <?php echo strtoupper($_POST["selFakultas"]); ?></p>
<p>Program Studi: <?php echo strtoupper($_POST["selProdi"]); ?></p>
</body>
</html>

<?php
$mahasiswa[0]="rudi";
$mahasiswa[1]="anto";
$mahasiswa[2]="joko";
$mahasiswa[3]="sinta";
echo "nama-nama mahasiswa : <br>";
$x=1;
for($i=0;$i<=3;$i++)
{
echo "$x. $mahasiswa[$i] <br>";
$x++;

}
?>

<?php
$arrBuah = array ("Mangga", "Apel", "Pisang", "Jeruk");
echo $arrBuah[0]; //Mangga
echo $arrBuah[3]; //Jeruk
$arrWarna = array();
$arrWarna[] = "Merah";
$arrWarna[] = "Biru";
$arrWarna[] = "Hijau";
$arrWarna[] = "Putih";
echo $arrWarna[0]; //Merah
echo $arrWarna[2]; //Hijau
?>

<?php

$angka=array(1,2,3,4,5,6,7,8,9,10);

for($i=0; $i < count($angka); $i++){


echo $angka[$i];
echo ",";
}

?>

You might also like