Creat Random Image With PHP

The way of creating random image in PHP

Page 1 of 1

3 Replies - 930 Views - Last Post: 07 January 2011 - 04:17 AM Rate Topic: -----

#1 Guest_annysharing*


Reputation:

Creat Random Image With PHP

Posted 06 January 2011 - 07:24 PM

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

Is This A Good Question/Topic? 0

Replies To: Creat Random Image With PHP

#2 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 922
  • View blog
  • Posts: 3,195
  • Joined: 19-January 10

Re: Creat Random Image With PHP

Posted 06 January 2011 - 07:59 PM

Uhh, no?


Wrong place man.
Was This Post Helpful? 1
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

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!

This post has been edited by CTphpnwb: 06 January 2011 - 08:01 PM

Was This Post Helpful? 1
  • +
  • -

#4 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,219
  • Joined: 23-August 08

Re: Creat Random Image With PHP

Posted 07 January 2011 - 04:17 AM

It's spam guys. Removed link and closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1