Kali ini ane mau posting tentang tugas salah satu matakuliah, tugasnya itu disuruh bikin daftar hargga bbm, ok langsung saja untuk tampilan programnya:
Gambar diatas adalah tampilan programnya, dimana liter awal dimulai 1, dan liter akhirnya 10, data yang ditampilkan yaitu data Bensin, solar, dan minyak tanah, untuk source codenya diabawah:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TABEL HARGA BBM</title>
</head>
<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
?>
<div align="center"><br />
<h1>DAFTAR HARGA BBM</h1>
</div>
<br />
<form co id="bahan_bakar_minyak" name="bahan_bakar_minyak" method="post" action="<?php echo $_SERVER['PHP_SELF']?>" />
<table border="1.7" align="center">
<tr>
<td bgcolor="#ff9999" align="center">Liter Awal</td>
<td bgcolor="#ff9999" align="center">Liter Akhir</td>
<td bgcolor="#ff9999" align="center">Bensin</td>
<td bgcolor="#ff9999" align="center">Solar</td>
<td bgcolor="#ff9999" align="center">Minyak Tanah</td>
</tr>
<tr>
<td align="center">
<select name="liter_awal" id="liter_awal">
<?php
for ($a=1;$a<=20;$a++){
echo "<option value='$a'"?>
<?php if ($_POST[liter_awal]=="$a") echo "selected"; ?>
<?php echo ">$a</option>";
}
?>
</select>
</td>
<td align="center">
<select name="liter_akhir" id="liter_akhir">
<?php
for ($a=1;$a<=20;$a++){
echo "<option value='$a'"?>
<?php if ($_POST[liter_akhir]=="$a") echo "selected"; ?>
<?php echo ">$a</option>";
}
?>
</select>
</td>
<td align="center">
<input type="checkbox" name="bensin" id="bensin" value="jenis" <?php if ($_POST[bensin]=="jenis") echo "checked"; ?>/>
</td>
<td align="center">
<input type="checkbox" name="solar" id="solar" value="jenis" <?php if ($_POST[solar]=="jenis") echo "checked"; ?> />
</td>
<td align="center">
<input type="checkbox" name="minyak_tanah" id="minyak_tanah" value="jenis" <?php if ($_POST[minyak_tanah]=="jenis") echo "checked"; ?> />
</td>
</tr>
<tr>
<td colspan="5" align="center">
<input type="submit" name="Tampilkan" id="Tampilkan" value="Tampilkan" />
</td>
</tr>
</table>
<hr color="pink" size="2" width="500" />
<?php
$liter_awal=0;
$liter_akhir=0;
$tampung=0;
$bensin="";
$solar="";
$minyak_tanah="";
$harga_bensin=8000;
$harga_solar=7000;
$harga_minyak_tanah=10000;
$liter_awal=$_POST[liter_awal];
$liter_akhir=$_POST[liter_akhir];
$bensin=$_POST[bensin];
$solar=$_POST[solar];
$minyak_tanah=$_POST[minyak_tanah];
?>
<?php
if($_POST[Tampilkan]=="Tampilkan"){ ?>
<?php
if ($liter_awal > $liter_akhir){
$tampung=$liter_awal;
$liter_awal=$liter_akhir;
$liter_akhir=$tampung;
}
if(($bensin=="jenis") && ($solar=="jenis") && ($minyak_tanah=="jenis"))
{ ?>
<table width="350" border="1" align="center">
<tr>
<td width="50" align="center">Liter</td>
<td width="100" align="center">Bensin</td>
<td width="100" align="center">Solar</td>
<td width="100" align="center">Minyak Tanah</td>
</tr>
<?php for($a=$liter_awal;$a<=$liter_akhir;$a++){
$harga_bensin2=$harga_bensin*$a;
$harga_solar2=$harga_solar*$a;
$harga_minyak_tanah2=$harga_minyak_tanah*$a;
echo "<tr><td align=right>$a</td><td align=right>";?>
<?php echo number_format($harga_bensin2,0,",",".");?>
<?php echo "</td><td align=right>";?>
<?php echo number_format($harga_solar2,0,",",".");?>
<?php echo "</td><td align=right>";?>
<?php echo number_format($harga_minyak_tanah2,0,",",".");?>
<?php echo "</td></tr>";}
}
else
if(($bensin=="jenis") && ($solar=="jenis"))
{ ?>
<table width="250" border="1" align="center">
<tr>
<td bgcolor="#ff9999" width="50" align="center">Liter</td>
<td width="100" align="center">Bensin</td>
<td width="100" align="center">Solar</td>
</tr>
<?php for($a=$liter_awal;$a<=$liter_akhir;$a++){
$harga_bensin2=$harga_bensin*$a;
$harga_solar2=$harga_solar*$a;
echo "<tr><td align=right>$a</td><td align=right>";?>
<?php echo number_format($harga_bensin2,0,",",".");?>
<?php echo "</td><td align=right>";?>
<?php echo number_format($harga_solar2,0,",",".");?>
<?php echo "</td></tr>";}
}
else
if(($bensin=="jenis") && ($minyak_tanah=="jenis"))
{ ?>
<table width="250" border="1" align="center">
<tr>
<td width="50" align="center">Liter</td>
<td width="100" align="center">Bensin</td>
<td width="100" align="center">Minyak Tanah</td>
</tr>
<?php for($a=$liter_awal;$a<=$liter_akhir;$a++){
$harga_bensin2=$harga_bensin*$a;
$harga_minyak_tanah2=$harga_minyak_tanah*$a;
echo "<tr><td align=right>$a</td><td align=right>";?>
<?php echo number_format($harga_bensin2,0,",",".");?>
<?php echo "</td><td align=right>";?>
<?php echo number_format($harga_minyak_tanah2,0,",",".");?>
<?php echo "</td></tr>";}
}
else
if(($solar=="jenis") && ($minyak_tanah=="jenis"))
{ ?>
<table width="250" border="1" align="center">
<tr>
<td width="50" align="center">Liter</td>
<td width="100" align="center">Solar</td>
<td width="100" align="center">Minyak Tanah</td>
</tr>
<?php for($a=$liter_awal;$a<=$liter_akhir;$a++){
$harga_solar2=$harga_solar*$a;
$harga_minyak_tanah2=$harga_minyak_tanah*$a;
echo "<tr><td align=right>$a</td>";?>
<?php echo "<td align=right>";?>
<?php echo number_format($harga_solar2,0,",",".");?>
<?php echo "</td><td align=right>";?>
<?php echo number_format($harga_minyak_tanah2,0,",",".");?>
<?php echo "</td></tr>";}
}
else
if($minyak_tanah=="jenis")
{ ?>
<table width="150" border="1" align="center">
<tr>
<td width="50" align="center">Liter</td>
<td width="100" align="center">Minyak Tanah</td>
</tr>
<?php for($a=$liter_awal;$a<=$liter_akhir;$a++){
$harga_minyak_tanah2=$harga_minyak_tanah*$a;
echo "<tr><td align=right>$a</td><td align=right>";?>
<?php echo number_format($harga_minyak_tanah2,0,",",".");?>
<?php echo "</td></tr>";}
}
else
if($bensin=="jenis")
{ ?>
<table width="150" border="1" align="center">
<tr>
<td width="50" align="center">Liter</td>
<td width="100" align="center">Bensin</td>
</tr>
<?php for($a=$liter_awal;$a<=$liter_akhir;$a++){
$harga_bensin2=$harga_bensin*$a;
echo "<tr><td align=right>$a</td><td align=right>";?>
<?php echo number_format($harga_bensin2,0,",",".");?>
<?php echo "</td></tr>";}
}
else
if($solar=="jenis")
{ ?>
<table width="150" border="1" align="center">
<tr>
<td width="50" align="center">Liter</td>
<td width="100" align="center">Solar</td>
</tr>
<?php for($a=$liter_awal;$a<=$liter_akhir;$a++){
$harga_solar2=$harga_solar*$a;
echo "<tr><td align=right>$a</td><td align=right>";?>
<?php echo number_format($harga_solar2,0,",",".");?>
<?php echo "</td></tr>";}
}
else
{
?>
<table width="200" border="1" align="center">
<tr>
<td width="200" align="center">Maaf! Bahan Bakar Anda harus diisi</td>
</tr>
<?php for($a=$liter_awal;$a<=$liter_akhir;$a++){
echo "<tr><td></td></tr>";}
}
}
else
{
?>
<table width="450" border="1" align="center">
<tr>
<td width="50" align="center">Liter</td>
<td width="100" align="center">Bensin</td>
<td width="100" align="center">Solar</td>
<td width="100" align="center">Minyak Tanah</td>
</tr>
<?php for($a=1;$a<=10;$a++){
$harga_bensin2+=$harga_bensin;
$harga_solar2+=$harga_solar;
$harga_minyak_tanah2+=$harga_minyak_tanah;
echo "<tr><td align=right>$a</td><td align=right>";?>
<?php echo number_format($harga_bensin2,0,",",".");?>
<?php echo "</td><td align=right>";?>
<?php echo number_format($harga_solar2,0,",",".");?>
<?php echo "</td><td align=right>";?>
<?php echo number_format($harga_minyak_tanah2,0,",",".");?>
<?php echo "</td></tr>";}
}
?>
</table>
</body>
</html>
Sekian dan terimakasih.......
No comments:
Post a Comment