<html>
<head>
<title>How To Import Excel (.xls) File To MySql Database Using PHP</title>
</head>
<body>
<center><h1>lp2maray</h1></center>
<form name="import_export_form" method="post" action="" enctype="multipart/form-data">
<label>Select Excel File : </label><input type="file" name="excelfile"/><br>
<input type="submit" name="form_submit"/>
</form>
</body>
</html>
<?php
if(isset($_POST['form_submit'])){
error_reporting(0);
require_once 'excel_reader2.php';
$filename = $_FILES['excelfile']['tmp_name'];
$data = new Spreadsheet_Excel_Reader($filename);
for ($x = 2; $x <= count($data->sheets[0]["cells"]); $x++) {
$first = $data->sheets[0]["cells"][$x][1];
$middle = $data->sheets[0]["cells"][$x][2];
$last = $data->sheets[0]["cells"][$x][3];
$sql = "INSERT INTO mytable (First,Middle,Last) VALUES ('$first','$middle','$last')";
echo $sql."\n";
//mysql_query($sql);
}
echo"<hr>";
echo $data->dump(true,true);
}
?>
==========================
Download Code
Sabtu, 11 Agustus 2018
Jumat, 10 Agustus 2018
Cuplik-Cuplik Code
Konvert Tanggal ke Hari:
function cekhari($tanggal){
$dayofweek = date('w', strtotime($tanggal));
$day= date('Y-m-d', strtotime(($day - $dayofweek).' day', strtotime($date)));
$hari="Senin";
if($day=="Sunday"){$hari="Minggu";}
else if($day=="Monday"){$hari="Senin";}
else if($day=="Tuesday"){$hari="Selasa";}
else if($day=="Wednesday"){$hari="Rabu";}
else if($day=="Thrusday"){$hari="Kamis";}
else if($day=="Friday"){$hari="Jumat";}
else if($day=="Saturday"){$hari="Sabtu";}
return $hari;
}
-----------------------------------------------------------------
function cekHuruf ada atau tidak
function cekData($cari,$database){
$ada=strlen(strstr($cari,$database));
$hasil=false;
if($ada>0){$hasil=true;}
return $hasil;
}
Contoh:
echo "<h1>##".cekData("LP2MARAY","Saya Belajar di LP2MARAY")."</h1>";
#hasilnya adalah 1 atau True
echo "<h1>##".cekData("LP2M ARAY","Saya Belajar di LP2MARAY")."</h1>";
function cekhari($tanggal){
$dayofweek = date('w', strtotime($tanggal));
$day= date('Y-m-d', strtotime(($day - $dayofweek).' day', strtotime($date)));
$hari="Senin";
if($day=="Sunday"){$hari="Minggu";}
else if($day=="Monday"){$hari="Senin";}
else if($day=="Tuesday"){$hari="Selasa";}
else if($day=="Wednesday"){$hari="Rabu";}
else if($day=="Thrusday"){$hari="Kamis";}
else if($day=="Friday"){$hari="Jumat";}
else if($day=="Saturday"){$hari="Sabtu";}
return $hari;
}
-----------------------------------------------------------------
function cekHuruf ada atau tidak
function cekData($cari,$database){
$ada=strlen(strstr($cari,$database));
$hasil=false;
if($ada>0){$hasil=true;}
return $hasil;
}
Contoh:
echo "<h1>##".cekData("LP2MARAY","Saya Belajar di LP2MARAY")."</h1>";
#hasilnya adalah 1 atau True
echo "<h1>##".cekData("LP2M ARAY","Saya Belajar di LP2MARAY")."</h1>";
#hasilnya adalah 0 atau False
Batasan Waktu Terhadap Order
$jamn=date("H:i:s");
$tgln=date("Y-m-d");
//cek apakah ada order di database
$sql="select * from `$tbso` where `status`='Order'";
$jum=getJum($conn,$sql);
if($jum > 0){
$arr=getData($conn,$sql);
foreach($arr as $d) {
$kode_so=$d["kode_so"];
$tanggal_so=$d["tanggal_so"];
$jam=$d["jam"];
$deskripsi=$d["deskripsi"];
$nama=$d["nama"];
$telepon=$d["telepon"];
$email=$d["email"];
$status=$d["status"];
$awal = strtotime("$tanggal_so $jam");//waktu order
$akhir = strtotime("$tgln $jamn");//waktu sekarang
$diff = $akhir - $awal;//selisih waktu
$jam = floor($diff / (60 * 60));
$menit = $diff - $jam * (60 * 60);
$MM=$menit / 60;
echo $kode_so.' Waktu tinggal: ' . $jam . ' jam, ' . floor( $MM ) . ' menit <br>';
if($MM>=$BATASMAX){//bila sudah lewat batasan menitnya
$not=" Expire = Waktu tinggal: ". $jam . " jam, " . floor( $menit / 60 ) . " menit";
echo $not;
$sql="update `$tbso` set `status`='Expire',`keterangan_order`='$not' where `kode_so`='$kode_so'";
$ubah=process($conn,$sql);
$sqlc="select * from `$tbsodetail` where `kode_so`='$kode_so'";
$arrc=getData($conn,$sqlc);
foreach($arrc as $dc) {
$idc=$dc["id"];
$kode_barangc=$dc["kode_barang"];
$jumlah=$dc["jumlah"];
$sqlm="update `$tbbarang` set `stok`=`stok`+'$jumlah' where `kode_barang`='$kode_barang'";
$up=process($conn,$sqlm);
}//for
}//if
}
}
$tgln=date("Y-m-d");
//cek apakah ada order di database
$sql="select * from `$tbso` where `status`='Order'";
$jum=getJum($conn,$sql);
if($jum > 0){
$arr=getData($conn,$sql);
foreach($arr as $d) {
$kode_so=$d["kode_so"];
$tanggal_so=$d["tanggal_so"];
$jam=$d["jam"];
$deskripsi=$d["deskripsi"];
$nama=$d["nama"];
$telepon=$d["telepon"];
$email=$d["email"];
$status=$d["status"];
$awal = strtotime("$tanggal_so $jam");//waktu order
$akhir = strtotime("$tgln $jamn");//waktu sekarang
$diff = $akhir - $awal;//selisih waktu
$jam = floor($diff / (60 * 60));
$menit = $diff - $jam * (60 * 60);
$MM=$menit / 60;
echo $kode_so.' Waktu tinggal: ' . $jam . ' jam, ' . floor( $MM ) . ' menit <br>';
if($MM>=$BATASMAX){//bila sudah lewat batasan menitnya
$not=" Expire = Waktu tinggal: ". $jam . " jam, " . floor( $menit / 60 ) . " menit";
echo $not;
$sql="update `$tbso` set `status`='Expire',`keterangan_order`='$not' where `kode_so`='$kode_so'";
$ubah=process($conn,$sql);
$sqlc="select * from `$tbsodetail` where `kode_so`='$kode_so'";
$arrc=getData($conn,$sqlc);
foreach($arrc as $dc) {
$idc=$dc["id"];
$kode_barangc=$dc["kode_barang"];
$jumlah=$dc["jumlah"];
$sqlm="update `$tbbarang` set `stok`=`stok`+'$jumlah' where `kode_barang`='$kode_barang'";
$up=process($conn,$sqlm);
}//for
}//if
}
}
Senin, 06 Agustus 2018
Shoutbox LP2mARAY
chatting.php
<script language="JavaScript" type="text/javascript">
function addSmiley(textToAdd){
document.formshout.pesanShout.value += textToAdd;
document.formshout.pesanShout.focus();
}
</script>
<link href="smiley/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' Haruslah memiliki nama @domain.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' Haruslah berupa angka.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' Haruslah angka antara '+min+' dan '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' Haruslah diisi terlebih dahulu.\n'; }
} if (errors) alert('Maaf, Terjadi beberapa kesalahan masukan data :\n'+errors);
document.MM_returnValue = (errors == '');
} }
</script>
<iframe src="shoutbox.php" width="100%" height="250" border="1" solid></iframe><br /><br />
<table class='date' width='100%'>
<form name="formshout" action="" method="POST">
<tr>
<td width='10%' class="highlight2">Nama</td>
<td width='90%'><input name='namaShout' type=text class=shout id="namaShout" value="<?php echo $_SESSION["cnama"];?>" disabled size='21'></td></tr>
<tr>
<td width='10%' class="highlight2">Email</td>
<td><input name='emailShout' type=text class=shout id="emailShout" value="<?php echo $_SESSION["cemail"];?>" disabled size='21'></td></tr>
<tr>
<td width='10%' valign='top' class='highlight2'>Pesan</td>
<td><textarea name='pesanShout' class=shout id="pesanShout" style='width: 100%; height: 35px;'></textarea></td></tr>
<tr><td colspan='2'>
<a onClick="addSmiley(':-)')"><img src='smiley/1.gif'></a>
<a onClick="addSmiley(':-(')"><img src='smiley/2.gif'></a>
<a onClick="addSmiley(';-)')"><img src='smiley/3.gif'></a>
<a onClick="addSmiley(';-D')"><img src='smiley/4.gif'></a>
<a onClick="addSmiley(';;-)')"><img src='smiley/5.gif'></a>
<a onClick="addSmiley(';:D;')"><img src='smiley/6.gif'></a>
</td></tr>
<tr>
<td colspan=2>
<input name="SimpanShout" type="submit" class onclick="MM_validateForm('namaShout','','R','emailShout','','RisEmail','pesanShout','','R');return document.MM_returnValue" value='Kirim''"shout>
<input class="shout" type="reset" name="reset" value="Reset">
</td></tr>
</form>
</table>
<hr color="#e0cb91" noshade="noshade" />
<?php
if(isset($_POST["SimpanShout"])){
$nama = anti_injection($_SESSION["cnama"]);
$email = anti_injection($_SESSION["cemail"]);
$pesan = anti_injection($_POST["pesanShout"]);
$tgl_sekarang=date("Y-m-d");
$jam_sekarang=date("h:m:s");
$statusadabadwords = "none";
$badWords = array("sex","xxx","viagra","http","porn");// daftar bad words
for($i = 0; $i <= count($badWords)-1; $i++){if (!(strpos($pesan, $badWords[$i]) == false)){$statusadabadwords = "ada";break;}}
if ($statusadabadwords == "none"){
$sql="INSERT INTO `$tbshoutbox`(`nama`, `email`, `pesan`, `tanggal`, `status`) VALUES('$nama', '$email', '$pesan', '$tgl_sekarang $jam_sekarang','Y')";
$proses=process($conn,$sql);
if (empty($proses)){
echo "<script>alert('Data Gagal Disimpan, Silakan Cek Data Anda...'); document.location.href='?mnu=chatting';</script>\n";
}
else{die("<script>location.href='?mnu=chatting';</script>");}
}//statusadabadwords
else{echo "<script>alert('Maaf data Anda mengandung kata-kata tidak sopan');document.location.href='?mnu=chatting';</script>";}
}//ISSET
function anti_injection($data){
$filter = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($data,ENT_QUOTES))));
return $filter;
}
?>
++++++++++++++++++++++++++
<?php
session_start();
require_once"koneksi.php";
?>
<link href="smiley/style.css" rel="stylesheet" type="text/css" />
<?php
$sql="SELECT * FROM `$tbshoutbox` WHERE `status`='Y' ORDER BY `id` DESC LIMIT 10";
$arr=getData($conn,$sql);
foreach($arr as $d) {
$email= $d["email"];
$nama= $d["nama"];
$pesan= $d["pesan"];
$tanggal= $d["tanggal"];
$pesan = str_replace(":-)", "<img src=\"smiley/1.gif\">", $pesan);
$pesan = str_replace(":-(", "<img src=\"smiley/2.gif\">", $pesan);
$pesan = str_replace(";-)", "<img src=\"smiley/3.gif\">", $pesan);
$pesan = str_replace(";-D", "<img src=\"smiley/4.gif\">", $pesan);
$pesan = str_replace(";;-)", "<img src=\"smiley/5.gif\">", $pesan);
$pesan = str_replace(";:D;", "<img src=\"smiley/6.gif\">", $pesan);
echo "<span class='shout'><b><a href='mailto:$email' target='_blank'>$nama</a> : </b></span>";
echo "<span class=shout>$pesan</span><br />";
echo "<span class=date><font color='#6515ff'>".$tanggal."#</font></span>";
echo "<hr color='#e0cb91' noshade='noshade' />";
}
function getData($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$arr = $rs->fetch_all(MYSQLI_ASSOC);
//foreach($arr as $row) {
// echo $row['nama_kelas'] . '*<br>';
//}
$rs->free();
return $arr;
}
?>
Download Code
GoogleMap Frame
<?php
echo"<div class='center_content'>";
echo "<div class='center_title_bar'>Lokasi Kami</b></div>";
echo "<div class='center_prod_box_big'>";
$url="http://maps.google.com/maps/ms?msa=0&msid=203038942996608606794.000499e7b9b2535ca5b0d&ie=UTF8&t=m&vpsrc=0&z=14&output=embed";
echo "<iframe width='96%' height='630' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='$url'></iframe><br />
<div align='center'>
<a href='$url' title='Lokasi Kita'><strong>Lihat Lebih Dekat</strong></a><br>LP2MARAY<br> Jakarta
</div>";
}
echo"</div></div>";
?>
echo"<div class='center_content'>";
echo "<div class='center_title_bar'>Lokasi Kami</b></div>";
echo "<div class='center_prod_box_big'>";
$url="http://maps.google.com/maps/ms?msa=0&msid=203038942996608606794.000499e7b9b2535ca5b0d&ie=UTF8&t=m&vpsrc=0&z=14&output=embed";
echo "<iframe width='96%' height='630' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='$url'></iframe><br />
<div align='center'>
<a href='$url' title='Lokasi Kita'><strong>Lihat Lebih Dekat</strong></a><br>LP2MARAY<br> Jakarta
</div>";
}
echo"</div></div>";
?>
Minggu, 05 Agustus 2018
BUKUTAMU ILU INU IMU
Membuat Bukutamu Captcha
<tr>
<td>scode
<td>
<td><img src='ydata/mycaptcha.php'></td>
</tr>
<tr>
<td>
<td>
<td>
<input type='text' name='kodecaptcha' size='6' maxlength='6'>
(Masukkan 6 kode diatas)
</td>
</tr>
ATAU CODE LENGKAPNYA bukutamu,php
<?php
echo"<link href=ydata/amazon.css' rel='stylesheet' type='text/css' />";
$s="select * from `$tbbukutamu` order by `kode_bukutamu` desc";
$q=mysql_query($s);
$jum=mysql_num_rows($q);
$th=date("y");
$bl=date("m")+0;if($bl<10){$bl="0".$bl;}
$kd="GSS".$th.$bl;//KEG1610001
if($jum > 0){
$d=mysql_fetch_array($q);
$idmax=$d["kode_bukutamu"];
$bul=substr($idmax,5,2);
$tah=substr($idmax,3,2);
if($bul==$bl && $tah==$th){
$urut=substr($idmax,7,3)+1;
if($urut<10){$idmax="$kd"."00".$urut;}
else if($urut<100){$idmax="$kd"."0".$urut;}
else{$idmax="$kd".$urut;}
}//==
else{
$idmax="$kd"."001";
}
}//jum>0
else{$idmax="$kd"."001";}
$kode_bukutamu=$idmax;
?>
<form action="" method="post">
<table width="407" style='border: 1pt dashed #0000CC;padding: 10px;'>
<tr>
<th width="48"><label for="kode_bukutamu">kode</label>
<th width="9">:
<th width="298"><b><?php echo $kode_bukutamu;?></b></th></tr>
<tr>
<td><label for="nama">nama</label>
<td>:<td><input name="nama" type="text" id="nama" value="<?php echo $nama;?>" size="35" />
</td></tr>
<tr>
<td height="24"><label for="telepon">telepon</label>
<td>:<td><input name="telepon" type="text" id="telepon" value="<?php echo $telepon;?>" size="15" />
</td></tr>
<tr>
<td height="24"><label for="email">email</label>
<td>:<td><input name="email" type="text" id="email" value="<?php echo $email;?>" size="25" />
</td></tr>
<tr>
<td><label for="pesan">pesan</label>
<td>:<td><textarea name="pesan" cols="45" id="pesan"><?php echo $pesan;?></textarea>
</td></tr>
<tr>
<td>scode
<td>
<td><img src='ydata/mycaptcha.php'></td>
</tr>
<tr>
<td>
<td>
<td>
<input type='text' name='kodecaptcha' size='6' maxlength='6'>
(Masukkan 6 kode diatas)
</td>
</tr>
<tr>
<td>
<td>
<td> <input name="Simpan" type="submit" id="Simpan" value="Simpan" />
<input name="kode_bukutamu" type="hidden" value="<?php echo $kode_bukutamu;?>" />
<a href="?mnu=bukutamu"><input name="Batal" type="button" id="Batal" value="Batal" /></a>
</td></tr>
</table>
</form>
ini isifile: ydata/mycaptcha.php
<?php
session_start();
header("Content-type: image/png");
$captcha_image = imagecreatefrompng("../ydata/captcha.png");
$captcha_font = imageloadfont("../ydata/font.gdf");
$captcha_text = substr(md5(uniqid('')),-6,6);
$_SESSION['captcha_session'] = $captcha_text;
$captcha_color = imagecolorallocate($captcha_image,0,0,0);
imagestring($captcha_image,$captcha_font,15,5,$captcha_text,$captcha_color);
imagepng($captcha_image);
imagedestroy($captcha_image);
?>
<?php
if(isset($_POST["Simpan"])){
$kode_bukutamu=strip_tags($_POST["kode_bukutamu"]);
$tanggal=date("Y-m-d");
$nama=strip_tags($_POST["nama"]);
$email=strip_tags($_POST["email"]);
$pesan=htmlentities($_POST["pesan"]);
$telepon=strip_tags($_POST["telepon"]);
$status="Aktif";
if($_POST["kodecaptcha"]==$_SESSION["captcha_session"]){
$sql="INSERT INTO `$tbbukutamu` (`kode_bukutamu` ,`tanggal` ,`nama` ,`telepon` ,`email` ,`pesan` ,`status`) VALUES ('$kode_bukutamu', '$tanggal', '$nama','$telepon', '$email', '$pesan', 'Y')";
$simpan=mysql_query($sql);
if($simpan) {echo "<script>alert('Data Bukutamu $nama Berhasil di simpan !');document.location.href='?mnu=bukutamu';</script>";}
else{echo"<script>alert('Data $nama Gagal di simpan...');document.location.href='?mnu=bukutamu';</script>";}
}//cocok captcha
else{
echo"<script>alert('Maaf, Security Code Anda salah...Seharusnya ".$_SESSION["captcha_session"].",Atau Silakan cek kembali...');document.location.href='javascript:history.go(-1)';</script>";}
}
?>
+++++++++++++++++++++++++++++++++++++++++++++++++
BUKUTAMU LIST
<?php
echo"<link href='ydata/amazon.css' rel='stylesheet' type='text/css' />";
$batas = 2;
$halaman = $_GET['halaman'];
if(empty($halaman)){$posisi = 0;$halaman = 1;}
else{$posisi = ($halaman-1) * $batas;}
$tampil = "SELECT * FROM `$tbbukutamu` LIMIT $posisi,$batas";
$hasil = mysql_query($tampil);
$no = $posisi+1;
while($r=mysql_fetch_array($hasil)){
$no++;
$tanggal=WKT($r["tanggal"]);
$nama=$r["nama"];
$kode_bukutamu=$r["kode_bukutamu"];
$email=$r["email"];
$telepon=$r["telepon"]; $telepon=substr($telepon,0,strlen($telepon)-3)."XXX";
$pesan=$r["pesan"];
$gab=$gab."<b>No. : $kode_bukutamu/$no</b><br>Nama : <a href='mailto:$email'>$nama</a><br>Telepon: $telepon<br>Pesan : $pesan ($tanggal)</p><hr color=#e0cb91 noshade=noshade />";
}
echo $gab;
$tampil2 = mysql_query("SELECT * FROM `$tbbukutamu`");
$jmldata = mysql_num_rows($tampil2);
$jmlhal = ceil($jmldata/$batas);
echo "<div class=paging>";
if($halaman > 1){
$prev=$halaman-1;
echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?halaman=$prev&mnu=bukutamu'>« Prev</a></span> ";
}
else{
echo "<span class=disabled>« Prev</span> ";
}
for($i=1;$i<=$jmlhal;$i++)
if ($i != $halaman){echo " <a href='$_SERVER[PHP_SELF]?halaman=$i&mnu=bukutamu'>$i</a> ";}
else{echo " <span class=current>$i</span> ";}
if($halaman < $jmlhal){$next=$halaman+1;echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?halaman=$next&mnu=bukutamu'>Next »</a></span>";}
else{echo "<span class=disabled>Next »</span>";}
echo "</div>";
echo "<p align=center>Total Pengunjung : <b>$jmldata</b> Orang...</p>";
?>
++++++++++++++++++++++++++++++++
bukutamu.php
<iframe src='bukutamu/bukutamulistuframe.php' width='100%' height='100%' border='1' solid></iframe><br />
isi bukutamulistuframe.php
<?php
error_reporting(0);
require_once "../koneksi.php";
echo"<link href='ydata/amazon.css' rel='stylesheet' type='text/css' />";
$batas = 10;
$halaman = $_GET['halaman'];
if(empty($halaman)){$posisi = 0;$halaman = 1;}
else{$posisi = ($halaman-1) * $batas;}
$tampil = "SELECT * FROM `$tbbukutamu` LIMIT $posisi,$batas";
$hasil = mysql_query($tampil);
$no = $posisi+1;
while($r=mysql_fetch_array($hasil)){
$no++;
$tanggal=WKT2($r["tanggal"]);
$nama=$r["nama"];
$kode_bukutamu=$r["kode_bukutamu"];
$email=$r["email"];
$telepon=$r["telepon"]; $telepon=substr($telepon,0,strlen($telepon)-3)."XXX";
$pesan=$r["pesan"];
$gab=$gab."<b>No. : $kode_bukutamu/$no</b><br>Nama : <a href='mailto:$email'>$nama</a><br>Telepon: $telepon<br>Pesan : $pesan ($tanggal)</p><hr color=#e0cb91 noshade=noshade />";
}
echo $gab;
$tampil2 = mysql_query("SELECT * FROM `$tbbukutamu`");
$jmldata = mysql_num_rows($tampil2);
$jmlhal = ceil($jmldata/$batas);
echo "<div class=paging>";
if($halaman > 1){
$prev=$halaman-1;
echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?halaman=$prev&mnu=bukutamu'>« Prev</a></span> ";
}
else{
echo "<span class=disabled>« Prev</span> ";
}
for($i=1;$i<=$jmlhal;$i++)
if ($i != $halaman){echo " <a href='$_SERVER[PHP_SELF]?halaman=$i&mnu=bukutamu'>$i</a> ";}
else{echo " <span class=current>$i</span> ";}
if($halaman < $jmlhal){$next=$halaman+1;echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?halaman=$next&mnu=bukutamu'>Next »</a></span>";}
else{echo "<span class=disabled>Next »</span>";}
echo "</div>";
echo "<p align=center>Total Pengunjung : <b>$jmldata</b> Orang...</p>";
?>
<?php
function WKT2($sekarang){
$tanggal = substr($sekarang,8,2)+0;
$bulan = substr($sekarang,5,2);
$tahun = substr($sekarang,0,4);
$judul_bln=array(1=> "Januari", "Februari", "Maret", "April", "Mei","Juni", "Juli", "Agustus", "September","Oktober", "Nopember", "Desember");
$wk=$tanggal." ".$judul_bln[(int)$bulan]." ".$tahun;
return $wk;
}
?>
++++++++++++++++++++++++++++++++++++++++++++
<?php
echo"<link href='ydata/amazon.css' rel='stylesheet' type='text/css' />";
echo "<table align=center width='100%' border=1>
<tr>
<th width='5%'>No</th>
<th width='30%'>Nama</th>
<th width='15%'>Telepon</th>
<th width='60%'>Pesan</th>
</tr>";
$batas = 10;
$halaman = $_GET['halaman'];
if(empty($halaman)){$posisi = 0;$halaman = 1;}
else{$posisi = ($halaman-1) * $batas;}
$tampil = "SELECT * FROM `$tbbukutamu` LIMIT $posisi,$batas";
$hasil = mysql_query($tampil);
$no = $posisi+1;
while($r=mysql_fetch_array($hasil)){
$kode_bukutamu=$r["kode_bukutamu"];
$nama=$r["nama"];
$email=$r["email"];
$telepon=$r["telepon"];
$pesan=$r["pesan"];
$telepon=substr($telepon,0,strlen($telepon)-3)."XXX";
if($no%2==0){
echo "<tr bgcolor='#cccccc'>
<td>$no</td>
<td><a href='mailto:$email'>$nama</a></td>
<td>$telepon</td>
<td>$pesan</td>
</tr>";
}
else {
echo "<tr bgcolor='#9999999'>
<td>$no</td>
<td><a href='mailto:$email'>$nama</a></td>
<td>$telepon</td>
<td>$pesan</td>
</tr>";
}
$no++;
}
echo "</table><br>";
$tampil2 = mysql_query("SELECT * FROM `$tbbukutamu`");
$jmldata = mysql_num_rows($tampil2);
$jmlhal = ceil($jmldata/$batas);
echo "<div class=paging>";
if($halaman > 1){
$prev=$halaman-1;
echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?halaman=$prev&mnu=bukutamu'>« Prev</a></span> ";
}
else{
echo "<span class=disabled>« Prev</span> ";
}
for($i=1;$i<=$jmlhal;$i++)
if ($i != $halaman){echo " <a href='$_SERVER[PHP_SELF]?halaman=$i&mnu=bukutamu'>$i</a> ";}
else{echo " <span class=current>$i</span> ";}
if($halaman < $jmlhal){$next=$halaman+1;echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?halaman=$next&mnu=bukutamu'>Next »</a></span>";}
else{echo "<span class=disabled>Next »</span>";}
echo "</div>";
echo "<p align=center>Total Pengunjung : <b>$jmldata</b> Orang...</p>";
?>
++++++++++++++++++++++++
BUKUTAMUUP.php
<?php
echo"<link href='ydata/amazon.css' rel='stylesheet' type='text/css' />";
$query = "SELECT * FROM `$tbbukutamu` order by `kode_bukutamu` asc";
$result = mysql_query($query);
$no=0;$gab="";
while ($r= mysql_fetch_array($result)) {
$no++;
$kode_bukutamu=$r["kode_bukutamu"];
$tanggal=WKT($r["tanggal"]);
$nama=$r["nama"];
$email=$r["email"];
$telepon=$r["telepon"]; $telepon=substr($telepon,0,strlen($telepon)-3)."XXX";
$pesan=$r["pesan"];
$gab=$gab."
No. : $kode_bukutamu/$no<br>
Nama : <a href='mailto:$email'>$nama</a><br>
Telepon : $telepon<br>
Pesan : $pesan ($tanggal)</p><hr color=#e0cb91 noshade=noshade />";
}
echo ("<marquee scrollamount=\"4\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\" direction=\"up\">$gab</marquee>");
?>
NB
Membaca Hari:
$seminggu = array("Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu");
$hari = date("w");
$hari_ini = $seminggu[$hari];
Menghindari TextPanjang:
$isi=nl2br($isi);
Langganan:
Postingan (Atom)
Selisih Waktu Berjalan
Berikut adalah fungsi PHP yang menghitung selisih hari antara tanggal saat ini dengan tanggal 2024-08-22 . Jika tanggal saat ini kurang dari...
-
<?php // <a href='download.php?file=$file' title='Download File'>Download Dokumen</a> $direktori = ...
-
Teman2 ...mungkin sering dapat kode random..... btw ini ada share sedikit ttg membuat soal random.....yang beda disini adalah sy menggunaka...
-
<?php $sql="select `id_admin` from `$tbadmin` order by `id_admin` desc"; $jum= getJum($conn,$sql); $kd="ADM"...