ระบบสุ่มแบบเนอร์อย่างง่ายไม่ต้องใช้ database สคริปท์จะทำการสุ่มแบนเนอร์มาแสดงทุกครั้งที่มีการรีโหลดเว็บเพจ ใช้คำสั่ง include ในการแสดงแบนเบอร์ สามารถรันบน PHP 4.x วิธีติดตั้ง copy โค้ดนี้ไปวางในโปรแกรม text editor ของคุณแล้วตั้งชื่อว่า banners.php
<?php
/*****
แก้ไข urls และ แบนเนอร์
*****/
$banners = array(
“http://www.website.com,image.png”,
“http://www.example.com,images/banner.jpg”
);
/*****
ส่วนนี้ไม่ต้องแก้ไขนะครับ
*****/
$randnum = rand(0, count($banners) - 1); // Choose a random banner
$exploded = explode(”,”, $banners[$randnum]); // Separate chosen banner by ,
$url = $exploded[0]; // Grab the URL for the banner
$img = $exploded[1]; // Grab the image for the banner
// Display the banner
echo “<a href=\”$url\”>”;
echo “<img src=\”$img\” border=\”0\” />”;
echo “</a>”;
?>
จากนั้นให้ใช้คำสั่ง include(”banners.php”); แทรกในตำแหน่งที่ต้องการให้แบนเนอร์แสดง Download : Random Banner (278) - 664 bytes