Presumably you'll be using JavaScript to randomly display pictures. But what if a picture's data (such as a link) changes frequently or is modified or added by the user? I have a solution here.
Put the picture information (such as name, address, link, etc.) in a TXT file (if MySQL is better, no matter). The PHP program is called by JavaScript in the HTML file, and the PHP program reads the image data randomly. See the procedure below:
Suppose there are TP.TXT content as follows: (each field represents ' Picture name ', ' Link Location ', ' Picture position ', tab between fields)
OSO www.oso.com.cn Www.oso.com.cn/image/logo.gif
163 www.163.com Image.163.com/images/logo.gif
Sohu www.sohu.com Www.sohu.com/image/logo.gif
Readrand.php (this program is actually generating a JavaScript language)
$arrayall =file ("Tp.txt"); Read tp.txt content into an array
$arrays =count ($arrayall);
if ($arrays ==1) {//because rand (0,0) is wrong
$selectrand = 0;
}else{
Srand (Double) microtime () *1000000);//set random number Seed
$selectrand =rand (0, $arrays-1);
}
$exstr =explode (Chr (9), $arrayall [$selectrand]);//randomly remove one from all and split
?>
document.write (' target= ' "new" > "width=" "height=" "alt=" ">");
HTML file
(You can put the scripty in the position you need, and you can add the settimeout () function to make a timed refresh)
http://www.bkjia.com/PHPjc/445151.html www.bkjia.com true http://www.bkjia.com/PHPjc/445151.html techarticle presumably you'll be using JavaScript to randomly display pictures. But what if a picture's data (such as a link) changes frequently or is modified or added by the user? I have a solution here. Put the picture ...