You will use javascript to randomly display images. But what if the image information (such as links) changes frequently or is modified or added by users? I have a solution here.
Put the image information (such as name, address, Link, etc.) in a TXT file (if MYSQL is better, or not ). The PHP program is called by javascript in HTML files, and the PHP program randomly reads image data. For the program, see:
Assume that the content of TP. TXT is as follows: (each field represents 'image name', 'link location', and 'image location' respectively, and TAB is used 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 actually generates a javascript LANGUAGE)
<?
$ Arrayall = file ("tp.txt" when reading the content of tp.txt to the array
$ Arrays = count ($ arrayall );
If ($ arrays = 1) {// because rand (0, 0) is wrong
$ Selectrand = 0;
} Else {
Srand (double) microtime () * 1000000); // sets the Random Seed.
$ Selectrand = rand (0, $ arrays-1 );
}
$ Exstr = explode (chr (9), $ arrayall [$ selectrand]); // randomly retrieve and divide all
?>
Document. write ('<a href = "<? Echo $ exstr [1];?> "Target =" new "> "Width =" 200 "height =" 50 "alt =" <? Echo $ exstr [0];?> "> </A> ');
HTML file
<Html>
<Body>
<Script language = 'javascript 'src = 'readrand. php'>
</Script>
</Body>
</Html>
(You can place scripty to the location you need, and add the setTimeout () function to implement timed refresh)