Blogroll

Senin, 21 Januari 2013

<?php session_start();
if (empty($_SESSION[user]) AND empty($_SESSION[pass])){
      echo "<center>Untuk mengakses halaman ini, Silahkan klik link berikut<br>";
  echo "<a href='loginadmin.php'><b>LOGIN</b></a></center>";
}else{
 ?>
<!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>Administrator Barang</title>
<style type="text/css">
<!--
body {
    margin-top: 0px;
    margin-bottom: 0px;
    background-image: url(../Windows%207%20ultimate%20collection%20of%20wallpapers%20(81)
.jpg);
    background-color: #10303F;
    background-repeat: repeat;
}
.style1 {
    color: #0000FF;
}
.style2 {
    color: #FFFFFF
}
.style15 {color: #FF0000}
.style16 {
    font-size: 12px;
    color: #FF0000;
}
a:link {
    color: #FFFF33;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #FFFF33;
}
a:hover {
    text-decoration: none;
    color: #FF0000;
}
a:active {
    text-decoration: none;
}
.style23 {font-size: 14px; color: #FFFFFF; }
.style34 {font-family: Georgia, "Times New Roman", Times, serif}
.style36 {
    color: #FFFFFF;
    font-size: 12px;
    text-decoration: none;
    font-family: Geneva, Arial, Helvetica, sans-serif;
}
.style39 {font-size: 10px}
.style40 {color: #000000}
.style41 {font-family: Geneva, Arial, Helvetica, sans-serif}
.style42 {
    color: #FFFFFF;
    font-family: Geneva, Arial, Helvetica, sans-serif;
    font-weight: bold;
    font-size: 14px;
}
.style43 {
    color: #FFFFFF;
    font-family: Geneva, Arial, Helvetica, sans-serif;
    font-size: 14px;
}
.style44 {font-size: 12px}
.style45 {font-size: 14px}
.style47 {color: #FFFFFF; font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; }
.style50 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; }
.style51 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; }
-->
</style>
</head>

<body>
<?php
include "koneksi.php";
$admin=$_SESSION[user];
//$kon=mysql_connect("localhost","root","");
//$db=mysql_select_db("elektrodb");
$nama=$_POST["txtnama"];
// jumlah data yang akan ditampilkan per halaman
$dataPerPage = 4;
// apabila $_GET['page'] sudah didefinisikan, gunakan nomor halaman tersebut,
// sedangkan apabila belum, nomor halamannya 1.

if(isset($_GET['page']))
{
$noPage = $_GET['page'];
}
else $noPage = 1;
// perhitungan offset
$offset = ($noPage - 1) * $dataPerPage;
$rsbarang=mysql_query("select* from barang where nmbarang like'%".$nama."%' ORDER BY kdbarang DESC LIMIT $offset, $dataPerPage");
// query SQL untuk menampilkan data perhalaman sesuai offset
//$query = "SELECT* FROM barang LIMIT $offset, $dataPerPage";
//$result = mysql_query($rsbarang) or die('Error');
?>
<script language="javascript">
function show_hari()
{
//membuat variabel bertipe array untuk nama hari
var NamaHari = new Array("Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat",
"Sabtu");
//membuat variabel bertipe array untuk nama bulan
var NamaBulan = new Array("Januari", "Februari", "Maret", "April", "Mei",
"Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
var sekarang = new Date();
var HariIni = NamaHari[sekarang.getDay()];
var BulanIni = NamaBulan[sekarang.getMonth()];
var tglSekarang = sekarang.getDate();
var TahunIni = sekarang.getFullYear();
document.write(HariIni + ", " + tglSekarang + " " + BulanIni + " " + TahunIni);
}
</script>
<table width="800" height="888" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
  <tr>
    <th height="265" colspan="4" background="gambar/banner.jpg" bgcolor="#FFFFFF" scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th width="197" height="33" bgcolor="#5EA8C1" scope="row"><div align="left" class="style1">
      <div align="left"><span class="style36">
        Hari ini : <script>show_hari();</script>
        </span></div>
    </div></th>
    <th width="293" height="33" bgcolor="#5EA8C1" scope="row">&nbsp;</th>
    <th width="169" bgcolor="#5EA8C1" scope="row"><div align="left"><span class="style43">Admin : <?php echo $admin;?></span></div></th>
    <th width="141" height="33" bgcolor="#5EA8C1" scope="row"><div align="right" class="style43"><a href="logout.php">Logout</a></div></th>
  </tr>
  <tr>
    <th height="3" colspan="4" bgcolor="#1B4458" scope="row"><div align="left" class="style1">
        <div align="center" class="style2"><span class="style34">
        <marquee behavior="alternate">
        </marquee>
    </span>    </div></th>
  </tr>
  <tr>
    <th height="27" colspan="4" bgcolor="#54727D" scope="row"><span class="style34">      <span class="style39">
      <span class="style40">
      <span class="style2">
      <span class="style44">
      <marquee behavior="alternate">
      <marquee behavior="alternate">
      <span class="style41">Selamat Datang Di kingelektronik.com </span>
      </marquee>
</marquee>
    </span>    </span>    </span>    </span>    </span></th>
  </tr>
  <tr>
    <th height="30" valign="middle" bgcolor="#5EA8C1" scope="row"><div align="center" class="style43">
      <div align="left"><span class="style42"><a href="adminpembelian.php">&lt;&lt;Data Pembelian</a></span></div>
    </div>
    <div align="center"></div>    <div align="center" class="style42"></div></th>
    <th height="30" colspan="2" valign="middle" bgcolor="#5EA8C1" scope="row"><span class="style42">Data Barang</span></th>
    <th height="30" valign="middle" bgcolor="#5EA8C1" scope="row"><div align="left" class="style43">
      <div align="right"><a href="adminpelanggan.php">Data Pelanggan&gt;&gt;</a></div>
    </div>
    <div align="center"></div></th>
  </tr>
  <tr>
    <th colspan="4" valign="top" bgcolor="#FFFFFF" scope="row"><form id="form1" name="form1" method="post" action="adminbarang.php">
      <table width="375" height="127" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="47" colspan="2" align="center">&nbsp;</td>
        </tr>
        <tr>
          <td width="147" height="24"><span class="style51">Nama Barang</span></td>
          <td width="188"><label>
            <input name="txtnama" type="text" id="txtnama" size="30" maxlength="30" />
          </label></td>
        </tr>
        <tr>
          <td height="33" align="center"><label></label></td>
          <td height="33" align="left" valign="middle"><label>
            <input name="cmdcari" type="submit" class="style1" id="cmdcari" value="Cari" />
            <input name="cmdbatal" type="submit" class="style1" id="cmdbatal" value="Batal" />
          </label></td>
        </tr>
        <tr>
          <td height="19" colspan="2">&nbsp;</td>
        </tr>
      </table>
      <table width="789" height="74" border="1" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="95" height="25" bgcolor="#5EA8C1"><div align="center" class="style43 style45">Kode</div></td>
          <td width="189" bgcolor="#5EA8C1"><div align="center" class="style43 style45">Nama</div></td>
          <td width="83" bgcolor="#5EA8C1"><div align="center" class="style43 style45">Harga</div></td>
          <td width="201" bgcolor="#5EA8C1"><div align="center" class="style43 style45">Spesifikasi</div></td>
          <td width="71" bgcolor="#5EA8C1"><div align="center" class="style43 style45">Stok</div></td>
          <td width="49" bgcolor="#5EA8C1"><span class="style43">Gambar</span></td>
          <td colspan="2" bgcolor="#5EA8C1"><div align="center"><span class="style45 style2 style41"><a href="inputbarang.php">Tambah</a></span></div></td>
        </tr>
        <?php
while ($row = mysql_fetch_row($rsbarang))
{
?>
        <tr>
          <td height="47"><div align="center" class="style15 style41 style44"><span class="style41 "><?php echo $row[0]; ?></span></div></td>
          <td><div align="left" class="style50"><span class="style41 "> <?php echo $row[1]; ?></span></div></td>
          <td><div align="left" class="style50"><span class="style41 "><?php echo "Rp ".number_format($row[2],0); ?></span></div></td>
          <td><div align="left" class="style50">
            <div align="justify"><?php echo $row[4]; ?>              </div>
          </div></td>
          <td><div align="center" class="style50"><?php echo $row[5]; ?></div></td>
          <td><img src="<?php echo $row[3]; ?>" alt="" width="60" height="50" /></td>
          <td width="42" bgcolor="#5EA8C1"><div align="center" class="style47"><a href="editbarang.php?kdbarang=<?php echo $row[0]; ?>">Ubah</a></div></td>
          <td width="52" bgcolor="#5EA8C1"><div align="center" class="style47"><a href="hapusbarang.php?kdbarang=<?php echo $row[0]; ?>">Hapus</a></div></td>
        </tr>
        <?php } ?>
      </table>
    
      <p>
        <?php
        // mencari jumlah semua data dalam tabel guestbook
$query = "SELECT COUNT(*) AS jumData FROM barang";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$jumData = $data['jumData'];
// menentukan jumlah halaman yang muncul berdasarkan jumlah semua data
$jumPage = ceil($jumData/$dataPerPage);
// menampilkan link previous
if ($noPage > 1) echo  "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1)."'>&lt;&lt; Prev</a>";
// memunculkan nomor halaman dan linknya
for($page = 1; $page <= $jumPage; $page++)
{
if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
{
if (($showPage == 1) && ($page != 2)) echo "...";
if (($showPage != ($jumPage - 1)) && ($page == $jumPage)) echo "...";
if ($page == $noPage) echo " ".$page." ";
else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a> ";
$showPage = $page;
}
}
// menampilkan link next
if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1)."'>Next &gt;&gt;</a>";
?>
      </p>
      </form>
      <p>&nbsp;</p>
      <p>&nbsp;</p></th>
  </tr>
 

  <tr>
    <th height="27" colspan="4" bgcolor="#5EA8C1" scope="row"><span class="style15">
      <marquee behavior="alternate" class="style16 style15"></marquee>    
    </span><span class="style23 style41">Hak Cipta @ 2012 <span class="style41">kingelektronik.com</span></span></th>
  </tr>
</table>
</body>
</html>
<?php
}
?>

0 komentar:

Posting Komentar

Site search

    Blogger news

    Blogroll

    About