Hi, programmer.
If you are disigning a website, you would like to add a random image to your site. Then you would write PHP script , intergrate the script to HTML code to provide random image display anywhere in your website. Also you can easily modify the script to make a more involved random imane selection .
Firstly, free and opensource php image script you need,
Secondly,
- Create an HTML element for the random image using "." Use CSS to format the image to your liking.
- Include the PHP script by placing the command "" between the "div" HTML tags. This calls the PHP routine "place_random_image" from the HTML code.
- Rename the HTML file, if necessary, by changing the extension from ".html" or ".htm" to ".php." This step is necessary to allow the browser to execute the PHP script.
- Add a new folder (or note the name of an existing folder) to contain your images. For example, create a folder called "random_images," and put all the image files into this folder. Assume, for this example, that you're using all JPEG images. Rename the images using consecutive numerals starting with "1" (for example, "1.jpg," "2.jpg" and so on).
- Make a new file called "place_random_image.php" using the text editor of your choice. This file will contain the random image PHP script.
- Write the PHP code in the file from Step 5. Write the following code for the script, organizing it in line-by-line fashion if you prefer: "; ?>. This script assumes your total number of images ("$total") is 10; adjust this number as appropriate.
- Run your HTML file. Try reloading it several times to be sure a different random image appears (almost) every time.
Do you have any suggestion?
Thanx in advance!
Anny
Creat Random Image With PHPThe way of creating random image in PHP
Page 1 of 1
3 Replies - 762 Views - Last Post: 07 January 2011 - 04:17 AM
Replies To: Creat Random Image With PHP
#2
Re: Creat Random Image With PHP
Posted 06 January 2011 - 07:59 PM
Uhh, no?
Wrong place man.
Wrong place man.
#3
Re: Creat Random Image With PHP
Posted 06 January 2011 - 08:00 PM
I suggest that you learn the order in which things occur! You do not run an html file. You make a request to the server, which runs php and returns the html that php generates. As long as you don't get this fact straight you will have significant problems developing code.
Edit: And no, the browser does not run php code!
Edit: And no, the browser does not run php code!
This post has been edited by CTphpnwb: 06 January 2011 - 08:01 PM
#4
Re: Creat Random Image With PHP
Posted 07 January 2011 - 04:17 AM
It's spam guys. Removed link and closed.
Page 1 of 1
|
|

New Topic/Question
This topic is locked
MultiQuote










|