mod6_studikasus1.php
<html>
<head>
<title>Studi Kasus 1 Modul 6</title>
</head>
<body>
<center>
<h1>
<?php
function greeting(){
$date = date ("G : i A");
if($date>=0 and $date<10){
echo "Selamat Pagi";
}
else if($date>=10 and $date<14){
echo "Selamat Siang";
}
else if($date>=15 and $date<19){
echo "Selamat Sore";
}
else if($date>=19 and $date<24){
echo "Selamat Malam";
}
else echo "Waktu salah";
}
?>
<?php greeting(); ?><br>
</h1>
<h3> Sekarang adalah
<?php
//Array Hari
$array_hari = array(1=>"Senin","Selasa","Rabu","Kamis","Jumat", "Sabtu","Minggu");
$hari = $array_hari[date("N")];
//Format Tanggal
$tanggal = date ("j");
//Array Bulan
$array_bulan = array(1=>"Januari","Februari","Maret", "April", "Mei", "Juni","Juli","Agustus","September","Oktober", "November","Desember");
$bulan = $array_bulan[date("n")];
//Format Tahun
$tahun = date("Y");
//Menampilkan hari dan tanggal
echo "hari $hari, tanggal $tanggal $bulan $tahun";
?>
<br>
Waktu menunjukkan pukul
<?php
//penulisan waktu
$date = date ("G : i A");
echo "$date WIB";
?>
</h3>
</body>
</html>
<head>
<title>Studi Kasus 1 Modul 6</title>
</head>
<body>
<center>
<h1>
<?php
function greeting(){
$date = date ("G : i A");
if($date>=0 and $date<10){
echo "Selamat Pagi";
}
else if($date>=10 and $date<14){
echo "Selamat Siang";
}
else if($date>=15 and $date<19){
echo "Selamat Sore";
}
else if($date>=19 and $date<24){
echo "Selamat Malam";
}
else echo "Waktu salah";
}
?>
<?php greeting(); ?><br>
</h1>
<h3> Sekarang adalah
<?php
//Array Hari
$array_hari = array(1=>"Senin","Selasa","Rabu","Kamis","Jumat", "Sabtu","Minggu");
$hari = $array_hari[date("N")];
//Format Tanggal
$tanggal = date ("j");
//Array Bulan
$array_bulan = array(1=>"Januari","Februari","Maret", "April", "Mei", "Juni","Juli","Agustus","September","Oktober", "November","Desember");
$bulan = $array_bulan[date("n")];
//Format Tahun
$tahun = date("Y");
//Menampilkan hari dan tanggal
echo "hari $hari, tanggal $tanggal $bulan $tahun";
?>
<br>
Waktu menunjukkan pukul
<?php
//penulisan waktu
$date = date ("G : i A");
echo "$date WIB";
?>
</h3>
</body>
</html>
Screenshot
STUDI KASUS 2
generate2.php
<html><body>
<?php
$b= $_POST['baris'];
$k= $_POST['kolom'];
if(ereg("[^0-9_-]", $b, $str))
{
echo 'Masukkan angka pada baris.';
}
elseif(ereg("[^0-9_-]", $k, $str))
{
echo 'Masukkan angka pada kolom.';
}
elseif (empty($b) || empty($k))
{
echo 'Fill in the empty fields.';
}
else {
echo "<table width='200' border='2' cellspacing='1' cellpadding='1'>";
for($i=0;$i<$b;$i++)
{
print "<tr>";
for($j=0;$j<$k;$j++)
{
print "<td> </td>";
}
}
print "</tr>";
echo "</table>";
}
?> </body></html>
<?php
$b= $_POST['baris'];
$k= $_POST['kolom'];
if(ereg("[^0-9_-]", $b, $str))
{
echo 'Masukkan angka pada baris.';
}
elseif(ereg("[^0-9_-]", $k, $str))
{
echo 'Masukkan angka pada kolom.';
}
elseif (empty($b) || empty($k))
{
echo 'Fill in the empty fields.';
}
else {
echo "<table width='200' border='2' cellspacing='1' cellpadding='1'>";
for($i=0;$i<$b;$i++)
{
print "<tr>";
for($j=0;$j<$k;$j++)
{
print "<td> </td>";
}
}
print "</tr>";
echo "</table>";
}
?> </body></html>
<!Doctype html>
<html lang="en">
<head>
<title>Studi Kasus 2 Modul 6
</title>
</head>
<body>
<form action='generate2.php' method='post'>
<table width="500" border="0" cellspacing="4" cellpadding="3">
<tr>
<td width="152">Jumlah Baris </td>
<td width="324">:
<input width='150' type='text' name='baris' size='15' /></td>
</tr>
<tr>
<td>Jumlah Kolom </td>
<td>:
<input width='150' type='text' name='kolom' size='15' /></td>
</tr>
<tr>
<td><div align="center"></div></td>
<td>
<div align="left">
<input type='submit' value='Generate'/>
</div></td>
</tr>
</table>
<p></br>
</p>
<p> </p>
<p></br>
</p>
</form>
</body>
</html>
ScreenshotTUGAS PRAKTIKUM 1
mod6_tp1_value.php
<?php
function jumlah($nilai){
$nilai++;
}
$input=9;
jumlah($input);
echo $input;
?>
Screenshotfunction jumlah($nilai){
$nilai++;
}
$input=9;
jumlah($input);
echo $input;
?>
mod6_tp1_reference.php
<?php
function jumlah(&$nilai){
$nilai++;
}
$input=9;
jumlah($input);
echo $input;
?>
Screenshotfunction jumlah(&$nilai){
$nilai++;
}
$input=9;
jumlah($input);
echo $input;
?>
TUGAS PRAKTIKUM 2
generate.php
<html>
<head>
<title>Hasil</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"?>
</head>
<body>
<?php
$rows = 1;
$columns = 1;
$cells = 1;
?>
<?php $rows = (int) $_POST["RowsTotal"]; ?>
<?php $columns = (int) $_POST["ColumnsTotal"]; ?>
<?php $cells = (int) $_POST["CellsTotal"]; ?>
Anda membuat <?php echo $rows; ?> baris,
<?php echo $columns; ?> kolom,
dan membutuhkan <?php echo $cells; ?> sel.<br/><br/>
<?php
$width = $columns * 75;
echo "<table width=".$width." border=1>";
$rw = 0;
$cel = 1;
while ($rw < $rows && $cel <= $cells){
echo "<tr>";
$cl = 0;
while ($cl < $columns)
{
if ($cel <= $cells){
echo "<td><div align=center>".$cel."</div></td>";
$cel++;
}
$cl++;
}
echo "</tr>";
$rw++;
}
echo "</table>";
?>
</body>
</html>
mod6_tp2.html<head>
<title>Hasil</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"?>
</head>
<body>
<?php
$rows = 1;
$columns = 1;
$cells = 1;
?>
<?php $rows = (int) $_POST["RowsTotal"]; ?>
<?php $columns = (int) $_POST["ColumnsTotal"]; ?>
<?php $cells = (int) $_POST["CellsTotal"]; ?>
Anda membuat <?php echo $rows; ?> baris,
<?php echo $columns; ?> kolom,
dan membutuhkan <?php echo $cells; ?> sel.<br/><br/>
<?php
$width = $columns * 75;
echo "<table width=".$width." border=1>";
$rw = 0;
$cel = 1;
while ($rw < $rows && $cel <= $cells){
echo "<tr>";
$cl = 0;
while ($cl < $columns)
{
if ($cel <= $cells){
echo "<td><div align=center>".$cel."</div></td>";
$cel++;
}
$cl++;
}
echo "</tr>";
$rw++;
}
echo "</table>";
?>
</body>
</html>
<html>
<head>
<title>Studi Kasus 2 Modul 6</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"?>
</head>
<body>
<form method="post" action="generate.php">
<p><h2>GENERATE TABEL</h2></p>
<table width="277"? border="0"?>
<tr>
<td width="89"?>Baris</td>
<td width="172"?><strong>: </strong><input name="RowsTotal" type="text" id="RowsTotal" onKeyUp="getmax();" onFocus="this.select();"></td>
</tr>
<tr>
<td><label>Kolom</label></td>
<td><strong>: </strong><input name="ColumnsTotal" type="text" id="ColumnsTotal" onKeyUp="getmax();" onFocus="this.select();"></td>
</tr>
<tr>
<td>Jumlah Sel</td>
<td><strong>: </strong><input name="CellsTotal" type="text" id="CellsTotal" onKeyUp="getmax();" onFocus="this.select();"></td>
</tr>
<tr>
<td>Sel Max</td>
<td><strong>: </strong><input name="maxcells" type="text" id="maxcells" readonly="readonly" style="background-color:#999999"?>
</td>
</tr>
<tr>
<td>
<div align="center">
<br />
<input type="reset" name="Reset" value="Reset">
</div></td>
<td>
<div align="right">
<br />
<input type="submit" name="Generate" value="Generate">
</div></td>
</tr>
</table>
</form>
<script language="JavaScript" type="text/javascript">
<!–
function getmax(){
var R = parseInt(document.getElementById('RowsTotal').value);
var C = parseInt(document.getElementById('ColumnsTotal').value);
var X = parseInt(document.getElementById('CellsTotal').value);
var cellmax = document.getElementById('maxcells');
var total = 'N/A';
total = R * C;
cellmax.value = new String(total);
if (X > total){
alert('Limit Exceed, max cells is ' + total);
document.getElementById('CellsTotal').value = new String();
}
}
//–>
</script>
</body>
</html>
Screenshot<head>
<title>Studi Kasus 2 Modul 6</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"?>
</head>
<body>
<form method="post" action="generate.php">
<p><h2>GENERATE TABEL</h2></p>
<table width="277"? border="0"?>
<tr>
<td width="89"?>Baris</td>
<td width="172"?><strong>: </strong><input name="RowsTotal" type="text" id="RowsTotal" onKeyUp="getmax();" onFocus="this.select();"></td>
</tr>
<tr>
<td><label>Kolom</label></td>
<td><strong>: </strong><input name="ColumnsTotal" type="text" id="ColumnsTotal" onKeyUp="getmax();" onFocus="this.select();"></td>
</tr>
<tr>
<td>Jumlah Sel</td>
<td><strong>: </strong><input name="CellsTotal" type="text" id="CellsTotal" onKeyUp="getmax();" onFocus="this.select();"></td>
</tr>
<tr>
<td>Sel Max</td>
<td><strong>: </strong><input name="maxcells" type="text" id="maxcells" readonly="readonly" style="background-color:#999999"?>
</td>
</tr>
<tr>
<td>
<div align="center">
<br />
<input type="reset" name="Reset" value="Reset">
</div></td>
<td>
<div align="right">
<br />
<input type="submit" name="Generate" value="Generate">
</div></td>
</tr>
</table>
</form>
<script language="JavaScript" type="text/javascript">
<!–
function getmax(){
var R = parseInt(document.getElementById('RowsTotal').value);
var C = parseInt(document.getElementById('ColumnsTotal').value);
var X = parseInt(document.getElementById('CellsTotal').value);
var cellmax = document.getElementById('maxcells');
var total = 'N/A';
total = R * C;
cellmax.value = new String(total);
if (X > total){
alert('Limit Exceed, max cells is ' + total);
document.getElementById('CellsTotal').value = new String();
}
}
//–>
</script>
</body>
</html>
Tidak ada komentar:
Posting Komentar