HarisMedia

  • Entries RSS
  • Comments RSS
  • Categories

    • Adsense
    • Agrikultura
    • Career
    • Humor
    • Internet
    • My Soul & Daily Life
    • News
    • Politic
    • Science and Technology
    • SEO
    • Software
    • Tentang Hidup
    • Tips & Trik
    • Web Development
    • Wordpress
  • Archives

    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • November 2007
    • October 2007
    • September 2006
    • August 2006
  • Recent Entries

    • Belajar banyak soal Virus!
    • Computer Problems
    • Tips pencarian google : Bagian 1 - Pencarian dasar
    • YouTube sudah BISA DIBUKA!
    • Luar Biasa!!
  • Top Comentators

    • kapanpun
  • Home
  • About
  • Contact
  • Links
  • Sitemap
Oct 25

[Tutorial] Nampilin poto secara acak (Random)

Web Development October 25th, 2007

anda punya koleksi poto yang ingin anda tampili di website/blog/jurnal online tercinta anda secara acak/random sehingga akan tampil berbeda dan terkesan update tiap kali halaman web yang memuat foto anda dibuka….caranya gambang…eh gampang bro!!!

Oke, kalo hosting anda support PHP, maka anda bisa memulainya sekarang

1. Tempatkan foto anda dalam satu folder/direktori yang sama (contoh : ./poto) - tips : akan terlihat lebih indah nantinya bila foto yang anda masukkan memiliki ukuran resolusi yang sama.

2. buka notepad…masukkan/salin script dibawah ini :

<?php

// masukkan path direktori dimana anda meletakkan folder poto diserver mis: $folder = ‘/poto’, tapi untuk mempermudah…lebih baik dikosongkan saja, untuk kemudian file ini nantinya kita simpan difolder yang sama didalam folder /poto

$folder = ”;

// Jenis ekstensi file yang bisa dibaca, silahkan tambahkan kalo ingin tambahan ekstensi yang lain (misal bmp), dipisahkan dengan spasi.

$exts = ‘jpg jpeg png gif’;

$files = array(); $i = -1; // Inisialisasi beberapa variabel
if (” == $folder) $folder = ‘./’;

$handle = opendir($folder);
$exts = explode(’ ‘, $exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) { // cek tiap ektensi
if (preg_match(’/\.’.$ext.’$/i’, $file, $test)) {
$files[] = $file;
++$i;
}
}
}
closedir($handle);
mt_srand((double)microtime()*1000000);
$rand = mt_rand(0, $i);

header(’Location: ‘.$folder.$files[$rand]); // Selesai!
?>

Kemudian simpan file dengan nama random.php / atau apapun sesuka hati anda

3. Dihalaman HTML tempat anda ingin menampilkan gambar, masukkan tag html (img) yang kemudian diarahkan ke random.php

contoh :

<html>
<head>
<title>test random poto</title>
</head>
<body>

<img src=”poto/random.php” alt=”random potoku tersayang” />

</body>
</html>

4. Selesai….emangnya mau ngapain lagi….sisanya (desain,tag html,css,dll) cari sendiri….atau nanti dilain tutor…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • blinkbits
  • BlinkList
  • Blue Dot
  • Bumpzee
  • connotea
  • description
  • Fark
  • feedmelinks
  • Fleck
  • Furl
  • IndianPad
  • Internetmedia
  • kick.ie
  • LinkaGoGo
  • Linkter
  • Live
  • Ma.gnolia
  • MisterWong
  • MyShare
  • Netvouz
  • NewsVine
  • NuJIJ
  • PlugIM
  • description
  • ppnow
  • Propeller
  • RawSugar
  • Rec6
  • Reddit
  • Scoopeo
  • description
  • Shadows
  • Simpy
  • Sk-rt
  • Slashdot
  • Smarking
  • Socialogs
  • SphereIt
  • Spurl
  • StumbleUpon
  • Taggly
  • TailRank
  • Technorati
  • ThisNext
  • TwitThis
  • Webride
  • Wists
  • Wykop
  • YahooMyWeb

Tags

This entry was posted on Thursday, October 25th, 2007 at 3:33 am and is filed under Web Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


« Mengenal PEAR
Lalu Lintas Internet Akan Diawasi 2008 »

Leave a Comment


Comments links could be nofollow free.

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

  • Blogroll

    • Anarch[Oi]!
    • arios
    • Arma
    • ArmaZone
    • CariKerja.info
    • HarisX@WP.com
    • Info-baru
    • InfoMaw
    • Kacrut
    • nirikip
    • Spirit of Me
    • step123
    • step456
    • Tiyan
    • Vitanouva Community
    • Zoira
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org

©© HarisMedia. Some Right Reserved. HarisMedia is proudly powered by WordPressand BlueMinded V.2.0 theme. Privacy Statement