0% found this document useful (0 votes)
46 views3 pages

Kumpulan Coding WEBsite Untuk Pemula

The document contains code snippets and functions for various PHP web development tasks like: 1) Defining colors, adding favicons, form validation, text truncation, and back button functions. 2) Creating buttons, boxes, and links that redirect using JavaScript. 3) Connecting to JavaScript libraries for datepickers, text editors, and calling automatic date/time. 4) Formatting currencies, generating random codes, and numbering tables automatically. 5) Functions for PDF generation, file uploads, calculating totals, and separating search codes.

Uploaded by

Rava F. Arram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views3 pages

Kumpulan Coding WEBsite Untuk Pemula

The document contains code snippets and functions for various PHP web development tasks like: 1) Defining colors, adding favicons, form validation, text truncation, and back button functions. 2) Creating buttons, boxes, and links that redirect using JavaScript. 3) Connecting to JavaScript libraries for datepickers, text editors, and calling automatic date/time. 4) Formatting currencies, generating random codes, and numbering tables automatically. 5) Functions for PDF generation, file uploads, calculating totals, and separating search codes.

Uploaded by

Rava F. Arram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Biru Tua = #0099FF

Biru Muda = #00CCFF

-- Hapus error
error_reporting(0);

-- Favicon
<link rel="shortcut icon" href="favicon.ico" />

-- Konfirmasi Hapus
onClick=\"return confirm('Apakah anda yakin ingin menghapus Berita...?')\"

-- Fungsi memotong text


<?php $position=100; $post = substr($row_ttng["isi"], 0, $position); echo
$post.'...'; ?>

-- Fungsi Javascript edit back history


<a href="produk_editc.php?id=<?php echo $row_prdk['id']; ?
>&referer=produk_cari.php?<?php echo $_SERVER['QUERY_STRING'] ?>"><img
src="../images/button-edit.gif" width="20" height="20" /></a>
if($updateSQL){
echo "<script type='text/javascript'>alert('Data produk berhasil
diedit...!'); location.href=\"$_GET[referer]\";</script>";
}

-- Tombol Link
<button style="background:#0099CC; color:#FFFFFF; width:100px; height:30px;"
onclick="window.location='beli.php?id=<?php echo $row_produk['id'];
?>'">Beli</button>
<button style="background:#0099CC; color:#FFFFFF; width:200px; height:30px;"
onclick="window.location='admin_tambah.php'">Tambah Admin Baru</button>

-- Tombol Kembali
<input type="button" value="Batal" onclick="self.history.back()" />
<input type="button" value="Batal" onclick="window.location='admin_tambah.php'" />
<input type="button" value="Batal" onclick="window.location='beli.php?id=<?php echo
$row_produk['id']; ?>'" />

-- javascript untuk box pesan


if($insertSQL){
echo "<script type='text/javascript'>alert('Kesalahan Akses!');
location.href=\"index.php\";</script>";
}
if($insertSQL){
echo "<script type='text/javascript'>alert('Komentar Berhasil Dikirim...!');
location.href=\"artikel_view.php?id=".$_POST['id_artikel']."\";</script>";
}

-- koneksi javascript untuk kalender


<link rel="stylesheet" type="text/css" href="../js/themes/base/ui.all.css"/>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="../js/ui/ui.core.js"></script>
<script type="text/javascript" src="../js/ui/ui.datepicker.js"></script>
<script type="text/javascript" src="../js/ui/i18n/ui.datepicker-id.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#tanggal").datepicker({
dateFormat:"dd MM yy",
changeMonth : true,
changeYear : true
});
});
</script>

-- koneksi javascript untuk Tinymcpuk text area

<script type="text/javascript" src="../js/tinymcpuk-0.3/tiny_mce.js"></script>


<script type="text/javascript" src="../js/tinymcpuk-0.3/settingku.js"></script>

<script type="text/javascript"
src="../js/tinymcpuk/tinymcpuk-0.3/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
})
</script>

-- fungsi panggil tanggal dan jam otomatis


<?php require_once('waktu.php'); ?>

value="<?php echo $sekarang; ?>"


<?php echo $sekarang, ' Jam ' ,date('H:i:s') ?>
<?php echo $sekarang2, ' Jam ' ,date('H:i') ?>
<?php echo date('d M Y H:i') ?>

-- fungsi css untuk tombol print


<style type="text/css">
@media print{
input.noPrint{display: none;}
}
</style>
<input class="noPrint" type="button" value="Print" onclick="window.print()">

-- fungsi panggil kode acak pada session


<?php require_once('acak.php'); ?>
<?php echo $kode_faktur; ?>

-- fungsi Rp. dan pemisah .- untuk mata uang rupiah


<?php echo 'Rp. ' . number_format($row_trans['total'], 0, ',', '.') .',-'; ?>

-- combo box untuk bulan dan tahun


<option value="Januari">Januari</option>
<option value="Februari">Februari</option>
<option value="Maret">Maret</option>
<option value="April">April</option>
<option value="Mei">Mei</option>
<option value="Juni">Juni</option>
<option value="Juli">Juli</option>
<option value="Agustus">Agustus</option>
<option value="September">September</option>
<option value="Oktober">Oktober</option>
<option value="November">November</option>
<option value="Desember">Desember</option>

<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>

-- fungsi nomor pada tabel otomatis


<?php $no = 1; do { ?>
<td><?php echo $no; ?></td>
<?php $no++; } while ($row_guru = mysql_fetch_assoc($guru)); ?>

-- fungsi mPDF (HTML to PDF)


<?php
// Define relative path from this script to mPDF
$nama_dokumen='laporan_bulanan_sporadik_skkt'; //Beri nama file PDF hasil.
define('_MPDF_PATH','../MPDF57/');
include(_MPDF_PATH . "mpdf.php");
$mpdf=new mPDF('utf-8', 'A4'); // Create new mPDF Document

//Beginning Buffer to save PHP variables and HTML tags


ob_start();
?>
<!--sekarang Tinggal Codeing seperti biasanya. HTML, CSS, PHP tidak masalah.-->
<!--CONTOH Code START-->
<?php
$html = ob_get_contents(); //Proses untuk mengambil hasil dari OB..
ob_end_clean();
//Here convert the encode for UTF-8, if you prefer the ISO-8859-1 just change for
$mpdf->WriteHTML($html);
$mpdf->WriteHTML(utf8_encode($html));
$mpdf->Output($nama_dokumen.".pdf" ,'I');
exit;
?>

-- Menghitung total keranjang belanja


Menghitung Total = $total += ($row_cart['harga']*$row_cart['qty']);

-- fungsi PHP upload file


move_uploaded_file($_FILES['foto']['tmp_name'], '../images/foto/'.$_FILES['foto']
['name']);

-- Pemisah Kode Pencarian


$colname_bulanan = '%'. $_GET['bulan'] .' '. $_GET['tahun'];

You might also like