Identifikasi Data
Desain Program
Programming
Diagnosa Program
Tidak
Benar
Tidak
Tidak Benar
Ya Dokumentasi
Selesai
Tentukan Pilihan A
Login Admin
Login Administrator
Home
Page Home
Berita
Page Berita
Galery Foto T
Hub. Kami
T Ada
A1
2 A1
Tentukan Pilihan
List Informasi T
Tambah Informasi
Logout T
List Informasi
Y Edit
Perbaiki Data
Simpan Y
Simpan Ke Tabel
Y Delete
R R
Y Tambah
Form Tambah
Simpan Y
Simpan Ke Tabel
Back To Admin
Lampiran 6. Contoh kode program dengan PHP Kode Program index.php <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="myportal.js"></script> <link href="css/style.css" rel="stylesheet" type="text/css"> <title>Sistem Informasi Alat Mesin Pertanian</title> </head> <body bgcolor=#CCCCFF> <? include "db_fungsi.php"; ?> <table border=0 width=980 align=center bgcolor="white"> <tr> <td> <? include "frmfind.php"; ?> </td> </tr> <tr> <td> <? include "header.php" ?> </td> </tr> <tr> <td bgcolor="#CCCCFF" width=100%> <table width=100%> <tr> <td width = 70% background=images/back.jpg> <Marquee behavior="alternate"><font size=3 color=red><b>KAMI MENYAJIKAN YANG TERBAIK UNTUK ANDA</b></font></Marquee> </td> </tr> </table> </td> </tr> <tr> <td valign=top height="10" width=100% background=images/back.jpg> <?
include "menutop.php"; ?> </td> </tr> <tr> <td height=900 valign=top> <? include "maintengah.php" ?> </td> </tr> <tr> <td align=center valign="middle" height=50> </td> </tr> <tr> <td background=images/back.jpg height=20> <? include "menubawah.php" ?> </td> </tr> </table> <br /> </body> </html>
Kode program berita.php <? $awal = 0; $akhir = 4; include "koneksi.php"; $jenis = $_REQUEST["jenis"]; $skey = $_REQUEST["skey"]; $sql = "select * from berita where jenis = '$jenis' limit $awal,$akhir"; $rs = mysql_query($sql); $i=1; $c=0; echo " <table border=0>"; while ($brs = mysql_fetch_array($rs))
{ $c=$c+1; $gmb = "images/$brs[image1]"; $kata = $brs[info]; if($i==1) { echo "<tr>"; $j=1; } if ($j<=2) { ?> <td width=50% valign=top style="border-bottom:#c7c7c7 1px dashed;border-left:#c7c7c7 1px dashed;border-right:#c7c7c7 1px dashed;bordertop:#c7c7c7 1px dashed;"> <img src="images/hdbullet.gif"><span class="midtitle"><a href="index.php?slink=detail.php&id1=<?=$brs[ID]?>&jenis=<?=$jenis?>"><?= $brs[judul]?></a></span> <br /> <p> <div id="gambarkiri"> <img src='images/<?=$brs[image1]?>' style="height: 60px; weight: 50px; border: 0;"> </div> <div id=urut><?=$brs[info]?></div> </p> </td> <? $j=$j+1; $i=$i+1; } if($i==1) { echo "</tr>"; } if ($j==3) { $i=1; } } if (($c % 2 ) <> 0 ) { ?> <td width=50% valign=top style="border-bottom:#c7c7c7 1px dashed;border-left:#c7c7c7 1px dashed;border-buttom:#c7c7c7 1px dashed;border-right:#c7c7c7 1px dashed;border-top:#c7c7c7 1px dashed;"> </td> <? }
echo "</table><br>"; ?> <table border=0 width=100%> <? $awal = $akhir; $akhir = 5; $sql = "select * from berita where jenis = '$jenis' limit $awal,$akhir"; $rs = mysql_query($sql); $i=1; $c=0; while ($brs = mysql_fetch_array($rs)) { $gmb = "images/$brs[image1]"; $kata = $brs[info]; ?> <tr> <td width=50% valign=top style="border-bottom:#c7c7c7 1px dashed;border-left:#c7c7c7 1px dashed;border-right:#c7c7c7 1px dashed;bordertop:#c7c7c7 1px dashed;"> <img src="images/hdbullet.gif"><span class="midtitle"> <a href="index.php?slink=detail.php&id1=<?=$brs[ID]?>&jenis=<?=$jenis?>"><?= $brs[judul]?></a></span> <br /> <p> <div class="pic_box" title="Image"> <img src='<?=$gmb?>' style="height: 60px; weight: 50px; border: 0;" border="0" alt="Image"> </div> <div id=urut><?=$kata?></div> </p> </td> </tr> <?}?> </table>
?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf8"> <meta name="robots" content="noindex, nofollow"> <link href="../sample.css" rel="stylesheet" type="text/css" /> <title></title> </head> <body> <font color=white> </font> <table bgcolor=white width=80% align=center height=80%> <tr> <td> <a href=index.php>Kembali Ke Home</a> </td> </tr> <tr><td> <? include "koneksi.php"; $_jenis = $_REQUEST["xjenis"]; $_info = $_REQUEST["FCKeditor2"]; $_headline = $_REQUEST["xheadline"]; $_judul = $_REQUEST["xjudul"]; $_isi = $_REQUEST["FCKeditor1"]; $_image1 = $_REQUEST["ximage1"]; $pil = $_REQUEST["pil"]; $id = $_REQUEST["id"]; $asal = $_REQUEST["xasal"]; if($_REQUEST["submit"]) { if($_REQUEST["aksi"]=="add") { $query = "INSERT INTO berita (headline,judul,isi,image1,asal,jenis,info)"; $query = $query." VALUES ('$_headline','$_judul','$_isi','$_file','$asal','$_jenis','$_info')"; $jalankan = mysql_query($query); if($jalankan) { echo "<h3 align=center> DATA BERHASIL DI SIMPAN</h3>"; }else { echo "<h3 align=center> DATA GAGAL DI SIMPAN</h3>";
} } if($_REQUEST["aksi"]=="edit") { $query = "UPDATE berita SET headline='$_headline',judul='$_judul',isi='$_isi',image1='$_file',asal='$asal',jenis= '$_jenis',info='$_info'"; $query = $query." where id = '$id'"; $jalankan = mysql_query($query); if($jalankan) { echo "<h3 align=center> DATA BERHASIL DI SIMPAN</h3>"; }else { echo "<h3 align=center> DATA GAGAL DI SIMPAN</h3>"; } } //echo $query; } ?> <form name=frm action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data"> <table border=0 width=100% cellpadding=0 cellspacing=0 style=bordercollapse: collapse bordercolor=#111111 align=center> <tr> <td> <table border=0 width=100%> <tr> <? $id=$_REQUEST["id"]; if($pil=="t") { echo "<td colspan=3 bgcolor=green><font color=white size=4><b> ADD DATA ARTIKEL </b></font> </td>"; echo ("<input type=hidden name=aksi size=45 value=add>"); } if($pil=="e") { echo "<td bgcolor=green colspan=3><font color=white size=4><b> EDIT DATA ARTIKEL </b></font></td>"; $query = "Select * from berita where id = '$id'"; $ok = mysql_query($query); $rs = mysql_fetch_array($ok); $_kode = $rs["ID"]; if($ok) {
echo ("<input type=hidden name=aksi size=45 value=edit> <input type=hidden name=id size=45 value=$_kode>"); } } ?> </tr> <tr> <td colspan=5></td> </tr> <tr> <td align=right>JENIS BERITA </td> <td> : </td> <td align=left> <Select name=xjenis> <? $query = "Select * from menu_atas"; $s_ok = mysql_query($query); while($s_rs = mysql_fetch_array($s_ok)) { if ($s_rs["jenis"]== $rs["jenis"]) { echo "<option value=$s_rs[jenis] selected>$s_rs[namamenu] </option>"; }else { echo "<option value=$s_rs[jenis]>$s_rs[namamenu] </option>"; } } $query = "Select * from menu_kiri"; $s_ok = mysql_query($query); while($s_rs = mysql_fetch_array($s_ok)) { if ($s_rs["jenis"]== $rs["jenis"]) { echo "<option value=$s_rs[jenis] selected>$s_rs[namamenu] </option>"; }else { echo "<option value=$s_rs[jenis]>$s_rs[namamenu] </option>"; } } ?>
</Select> </tr> <tr> <td align=right>JUDUL</td> <td> : </td> <td align=left><textarea name=xjudul rows=1 cols=80><?=$rs[judul]?></textarea> </td> </tr> <tr> <td align=right>ASAL ARTIKEL</td> <td> : </td> <td align=left><textarea name=xasal rows=1 cols=80><?=$rs[asal]?></textarea> </td> </tr> <tr> <td align=right>Informasi Awal</td> <td> : </td> <td align=left> <?php $info = $rs[info]; $sBasePath = $_SERVER['PHP_SELF'] ; $sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ; $sFCKeditor = new FCKeditor('FCKeditor2') ; $sFCKeditor->BasePath = $sBasePath ; $sFCKeditor->Height = 400; $sFCKeditor->Width = "80%"; $sFCKeditor->Value = $info ; $sFCKeditor->Create() ; ?> </td> </tr> <tr> <td align=left colspan=3> Detail Informasi <hr /><br> <?php $ss = $rs[isi]; $sBasePath = $_SERVER['PHP_SELF'] ; $sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ; $oFCKeditor = new FCKeditor('FCKeditor1') ; $oFCKeditor->BasePath = $sBasePath ; $oFCKeditor->Height = 600; $oFCKeditor->Width = "100%"; $oFCKeditor->Value = $ss ; $oFCKeditor->Create() ; ?> </td> </tr>
</table> </td> </tr> <tr> <td><hr /> </td> </tr> <tr> <td align=left> <input type=submit name=submit value=' SIMPAN '> <input type=reset name=reset value=' CANCEL '> </td> </tr> </table> </form> </td> </tr> </table> <font color=white> <a href=index.php>Kembali Ke Home</a> </font>