Sabtu, 19 Mei 2012

Auto BackUp MySQL Database

Suatu hal yang penting untuk melakukan backup database hosting anda.
Tujuannya adalah untuk berjaga-jaga kalau terjadi masalah dengan website anda, seperti:
  • Diserang oleh hacker
  • Hosting anda suspend
  • Dan error karena kesalahan anda sendiri
Diantara ketiga alasan tersebut, alasan terakhir yang paling sering terjadi, apalagi bagi anda yang sering mengutak-atik web anda, seperti instal addon/plugin/applikasi tambahan lainnya.
Tentunya anda harus melakukan backup secara rutin terhadap database anda, kalau tidak backup yang anda punya sudah tidak update lagi. Sebagai contoh, jika anda melakukan backup setiap 1bulan sekali, maka jika terjadi bencana pada database anda, data pada tanggal backup terakhir sampai tanggal terjadi bencana akan hilang. Dalam kasus anda melakukan backup setiap 1bulan, maka kemungkinan data selama 30 hari bisa hilang.

Kamis, 17 Mei 2012

Membuat Link Window PopUP Tampil Di Tengah Layar

Ketika anda membuat postingan adakalanya anda perlu menyisip kan sebuah link pada postingan anda.Dan saya yakin setiap blogger pastinya sudah tau bagai mana cara membuat link tersebut,karena membuat link merupakan bagian dari keharusan yang anda kuasai dalam dunia per blogan (Dunia Tukang blog).Tapi bagai manakah jika anda ingin menampilkan Window Popup ketika anda klik link tersebut tampil di tengah layar monitor? Jika anda ingin membuat nya ikuti langkah langkah di bawah ini :




1. Silahkan login ke blogger dengan ID anda.

2. Pilih Design/rancang .

3. Pilih Edit HTML .

4. Backup terlebih dahulu templete anda , klik pada tulisan Download Full Template

5.Cari Kode seperti di bawah ini (Gunakan Ctrl+F untuk mencari kode).

]]></b:skin>

6. Copy kode dibawah ini, lalu pastekan di bawah kode tadi.

<script language="javascript">
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
</script>

Rabu, 16 Mei 2012

Display data from mysql into combobox in PHP

For very beginners It is not easier to display data from required mysql table into combobox in PHP. Again after call any javascript function from that control’s onClick which will submit the page, always display only first or last data into combobox as well as it takes same value as input which bother developers. So in php there is easier way to handle such a problem. I have a table named casa_session from where I have to display session_title into select field. The codes are follows:

<? include(“connection.php”) ?>

<TR HEIGHT=”25″>
<TD colspan=”2″>Semester</TD>
<TD>
<select name=”salSemesterID” onClick=”submitCboSemester();”>
<?php
$query_disp=”SELECT * FROM casa_semester order by semester_id asc”;
$result_disp = mysql_query($query_disp, $conn);
while($query_data = mysql_fetch_array($result_disp))
{
?>
<option value=”<? echo $query_data['semester_id']; ?>”<?php if ($query_data['semester_id']==$_POST['salSemesterID']) {?>selected<? } ?>><? echo $query_data['name']; ?></option>
<? } ?>
</select>
</TD>



Sumber : http://afruj.wordpress.com/2008/06/26/display-data-from-mysql-into-combobox-in-php/

Class & ID Selector CSS



Masih ingat kan pada pelajaran syntax CSS bagian pertama yang di tulis adalah selector. Pada contoh-contoh di pelajaran sebelumnya, anda melihat penggunaan tag HTML sebagai selector.
Misalkan anda membuat kode CSS untuk tag <h1>. Sekarang bagaimana jika anda ingin memformat tag <h1> dengan warna / property berbeda? Misalkan, anda ingin tag <h1> di kolom kiri berwarna biru sementara tag <h1> di kolom tengah berwarna hitam.
Untuk kasus seperti ini, anda bisa menggunakan Class selector dan ID selector.

Class Selector

Class selector adalah penggabungan beberapa properties yang digunakan lebih dari satu kali.
Cara penulisan Class Selector:
.nama-class {property:value;}
Untuk menempelkan class ke dalam tag HTML:
taghtml.nama-class {Property:value;}
Perhatikan tanda titik di setiap awal nama Class. Jika anda ingin menggunakan class selector di luar kode HTML anda menggunakan tag <div class=nama-class> dan di akhiri dengan tag </div>.
Contoh:
Penulisan kode CSS:
.tengah {text-align:center;}
p.tengah {color:red;}
h1.kiri {color:blue;}
h1.tengah {color:black;}
Pemakaian kode CSS
<div class=tengah>
<p>Teks tengah akan berwarna merah.</p>
<h1 > Tag H1 tengah akan berwarna hitam</h1>
</div>
<h1 class=kiri>Tag H1 kiri akan berwarna biru</h1>

Selasa, 15 Mei 2012

PHP str_replace() Function


Definition and Usage

The str_replace() function replaces some characters with some other characters in a string.
This function works by the following rules:
  • If the string to be searched is an array, it returns an array
  • If the string to be searched is an array, find and replace is performed with every array element
  • If both find and replace are arrays, and replace has fewer elements than find, an empty string will be used as replace
  • If find is an array and replace is a string, the replace string will be used for every find value

Syntax

str_replace(find,replace,string,count)

jQuery Print Area


jquerynya di sini :
http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js
pluginsnya di sini :
http://plugins.jquery.com/project/PrintArea
(save as .js aja)


<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="printarea.js"></script>
<script>
$(document).ready(function(){
$("#tombolnya").click(function(){
$("#kartunya").printArea();
});
});
</script>
<div id="kartunya">
Nama : .... <br>
Jenis Kelamin : .... <br>
Foto : .... <br>
Alamat : .... <br>
</div>
<input type='button' id='tombolnya' value='print atasnya ini'>


atau klo pengen lebih gaul, export on the fly ke pdf aja...
tar nongolnya bentuk pdf, tinggal pincit tombol print aja ^^
http://www.fpdf.org/

(tinggal tambahin ke requirement aplikasi, install acrobat reader klo mau print)

Senin, 14 Mei 2012

Membuat Script PHP untuk Rekap Data dari Data Mentah

Pada artikel kali ini akan dibahas mengenai cara membuat script untuk menghasilkan rekap data, yang semula berasal dari data mentah MySQL. Script ini dibuat dengan PHP.

Sebagai studi kasus, kita akan mengambil data tentang mahasiswa. Adapun struktur tabel untuk menyimpan data mahasiswa ini adalah sebagai berikut:
1.CREATE TABLE mahasiswa (
2.nim varchar(8),
3.namaMhs varchar(20),
4.PRIMARY KEY (nim)
5.)
dan
1.CREATE TABLE jurusan (
2.kodeJurusan varchar(3),
3.namaJurusan varchar(10),
4.PRIMARY KEY (kodeJurusan)
5.)
Adapun sampel data untuk tabel mahasiswa adalah:
01.insert  into mahasiswa values
02.('M0197001', 'A'),
03.('M0197002', 'B'),
04.('M0197003', 'C'),
05.('M0197004', 'D'),
06.('M0198001', 'E'),
07.('M0198002', 'F'),
08.('M0199001', 'G'),
09.('M0199002', 'H'),
10.('M0199003', 'I'),
11.('M0297001', 'J'),
12.('M0297002', 'K'),
13.('M0297003', 'L'),
14.('M0298001', 'M'),
15.('M0298002', 'N'),
16.('M0298003', 'O'),
17.('M0298004', 'P'),
18.('M0298005', 'Q'),
19.('M0299001', 'R'),
20.('M0299002', 'S'),
21.('M0299003', 'T'),
22.('M0397001', 'U'),
23.('M0397002', 'V'),
24.('M0398001', 'W'),
25.('M0398002', 'X'),
26.('M0399001', 'Y'),
27.('M0399002', 'Z');
Dalam data di atas, terdapat 26 data mahasiswa yang terdiri dari beberapa tahun angkatan, yaitu Angkatan 97, 98 dan 99, yang tersebar di setiap jurusan. Jurusan apa saja yang ada? ini dia data untuk tabel Jurusan:
1.insert into jurusan values
2.('M01', 'Matematika'),
3.('M02', 'Fisika'),
4.('M03', 'Kimia');
Nah.. rekap yang akan dibuat adalah menampilkan jumlah mahasiswa per angkatan dan per tahun angkatan, serta jumlah mahasiswa untuk per jurusan. Perhatikan output dari rekap berikut ini:

Minggu, 13 Mei 2012

Mengapitalkan Isian dengan jQuery

<script type="text/javascript"
        src="jquery-1.5.1.min.js"></script>



<script type="text/javascript">
   $(document).ready(function() {
      $("input").keyup(function(e) {
         var isi = $(e.target).val();
         $(e.target).val(isi.toUpperCase());
      });
   });
</script>

Sumber : http://ingatscript.blogspot.com/

PHP For Each Loop

We have an associative array that stores the names of people in our company as the keys with the values being their age. We want to know how old everyone is at work so we use a Foreach loop to print out everyone's name and age.

PHP Code:

$employeeAges;
$employeeAges["Lisa"] = "28";
$employeeAges["Jack"] = "16";
$employeeAges["Ryan"] = "35";
$employeeAges["Rachel"] = "46";
$employeeAges["Grace"] = "34";

foreach( $employeeAges as $key => $value){
 echo "Name: $key, Age: $value <br />";
}

Display:

Name: Lisa, Age: 28
Name: Jack, Age: 16
Name: Ryan, Age: 35
Name: Rachel, Age: 46
Name: Grace, Age: 34
The syntax of the foreach statement is a little strange, so let's talk about it some.

Converting a String to Upper Case - strtoupper

The strtoupper function takes one argument, the string you want converted to upper case and returns the converted string. Only letters of the alphabet are changed, numbers will remain the same.

PHP Code:

$originalString = "String Capitalization 1234"; 

$upperCase = strtoupper($originalString);
echo "Old string - $originalString <br />";
echo "New String - $upperCase";

Display:

Old string - String Capitalization 1234
New String - STRING CAPITALIZATION 1234
One might use this function to increase emphasis of a important point or in a title. Another time it might be used with a font that looks very nice with all caps to fit the style of the web page design.
A more technical reason would be to convert two strings you are comparing to see if they are equal. By converting them to the same capitalization you remove the possibility that they won't match simply because of different capitalizations.

PHP - String Explode

The PHP function explode lets you take a string and blow it up into smaller pieces. For example, if you had a sentence you could ask explode to use the sentence's spaces " " as dynamite and it would blow up the sentence into separate words, which would be stored in an array. The sentence "Hello, I would like to lose weight." would look like this after explode got done with it:
  1. Hello,
  2. I
  3. would
  4. like
  5. to
  6. lose
  7. weight.
The dynamite (the space character) disappears, but the other stuff remains, but in pieces. With that abstract picture of the explode function in mind, lets take a look at how it really works.

The explode Function

The first argument that explode takes is the delimiter (our dynamite) which is used to blow up the second argument, the original string. explode returns an array of string pieces from the original and they are numbered in order, starting from 0. Lets take a phone number in the form ###-###-#### and use a hyphen "-" as our dynamite to split the string into three separate chunks.

PHP Code:

$rawPhoneNumber = "800-555-5555"; 

$phoneChunks = explode("-", $rawPhoneNumber);
echo "Raw Phone Number = $rawPhoneNumber <br />";
echo "First chunk = $phoneChunks[0]<br />";
echo "Second chunk = $phoneChunks[1]<br />";
echo "Third Chunk chunk = $phoneChunks[2]";

Display:

Raw Phone Number = 800-555-5555
First chunk = 800
Second chunk = 555
Third Chunk chunk = 5555