Use JavaScriptPHP to randomly display images-PHP source code

Source: Internet
Author: User
Tags random seed
Ec (2); you must use javascript to randomly display images. However, the materials (such as links) of fake films often change or are modified or added by users. What should I do? 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. Readrand. php (this program actually generates a javascript script ec (2); script

You will use javascript to randomly display images. However, the materials (such as links) of fake films often change or are modified or added by users. What should I do? 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.

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 ('"target =" new ">" width = "200" height = "50" alt =" "> ');

HTML file


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.