|
 |
|
อยากทราบวิธีการ random ตัวเลขใน textfile มาแสดงครับ |
|
 |
|
|
 |
 |
|
PHP rand()
|
 |
 |
 |
 |
Date :
2009-11-13 14:20:16 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมก็อยากได้ประมานนี้รบกนพี่ขอหน่อยนะครับ จะเอามาศึกษาอะครับ ของผม rand แบบแผนที่ท่องเทียวอะครับ
|
 |
 |
 |
 |
Date :
2009-11-18 14:35:21 |
By :
บอย |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
$imglist = array('banner1.gif', 'banner2.gif', 'banner3.gif' , 'banner4.gif');
$linklist = array('link1.php', 'link2.php', 'link3.php', 'link4.php');
$lastAd = @$_COOKIE['lastAd'] ;
$id = rand(0, count($imglist)-1) ;
while ($id == $lastAd) {
$id = rand(0, count($imglist)-1) ;
}
setcookie("lastAd", $id , time()+3600*24*2 );
$imgfile = $imglist[$id];
$link= $linklist[$id];
?>
<h3>ยินดีต้อนรับ</h3>
ลองคลิก refresh หรือเปิดเวบเข้ามาใหม่ ภาพโฆษณาจะหมุนเวียนสลับ สุ่มอัตโนมัติ <br>
<a href=<?=$link?>><img src= <?=$imgfile?> border=1> </a> <br>
บ้ายบาย
อาจจะเกี่ยวหรือไม่ เอาไปลองเล่นดู ก็ได้นะครับ
|
 |
 |
 |
 |
Date :
2009-11-18 14:52:20 |
By :
zonerelax |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|