• 0

image rotation


Question

i was wondering how would i go about making image's rotate using php

(basically tell me but dont post any code i want to make it myself)

thanks :ninja:

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

I used a random script, first images are listed in an array, then a random number is generated, and lastly an image is chosen depending on the number using if > or < statments.

Link to comment
Share on other sites

  • 0

i'd stuck the urls of images in an array, use the choose a random number of array function (array_rand() :ninja: ) and then echo ( :ninja: ) the one that it choses!

Link to comment
Share on other sites

  • 0

What type of rotation are you talking about? Like, rotate the picture 90 degrees to the right, or like show picture 1, then 2, 3, 4 etc.?

Link to comment
Share on other sites

  • 0

hmmm... all i wanted was to display was to display one image then move on to the next and so on until it got to the "end" and went back to the start thanks zetter btw and IPv6

Link to comment
Share on other sites

  • 0

You can use either an array or just a random number. Heres how I used to do my random sigs:

With an associative array:

&lt;? 
	//Associative array. Holds an integer value for each file name.
	$array = array(
  1 =&gt; 'sig1.jpg',
  2 =&gt; 'sig2.jpg',
  3 =&gt; 'sig3.jpg',
  4 =&gt; 'sig4.jpg'.
  5 =&gt; 'sig5.jpg',
  6 =&gt; 'sig6.jpg',  
  7 =&gt; 'sig7.jpg'  
	);

	//Creates the random number based on the number of images in the array.
	$random = mt_rand(1,7);

	//Sets the image name.
	$image = "$array[$random]";

	//Displays the image.
	header("Location: $image");
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");             // Date in the past
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); // always modified
	header("Cache-Control: no-cache, must-revalidate");           // HTTP/1.1
	header("Pragma: no-cache");                                   // HTTP/1.0
?&gt;

With just a random number:

&lt;? 
	$lower = 1;
	$upper = 7;
	$random_number = mt_rand($lower, $upper);
	$image = "$random_number.jpg";

	header("Location: $image");
?&gt;

With this one, you just number all of the images you want rotated.

Link to comment
Share on other sites

  • 0
You can use either an array or just a random number. Heres how I used to do my random sigs:

With an associative array:

&lt;? 
	//Associative array. Holds an integer value for each file name.
	$array = array(
  1 =&gt; 'sig1.jpg',
  2 =&gt; 'sig2.jpg',
  3 =&gt; 'sig3.jpg',
  4 =&gt; 'sig4.jpg'.
  5 =&gt; 'sig5.jpg',
  6 =&gt; 'sig6.jpg',  
  7 =&gt; 'sig7.jpg'  
	);

	//Creates the random number based on the number of images in the array.
	$random = mt_rand(1,7);

	//Sets the image name.
	$image = "$array[$random]";

	//Displays the image.
	header("Location: $image");
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");             // Date in the past
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); // always modified
	header("Cache-Control: no-cache, must-revalidate");           // HTTP/1.1
	header("Pragma: no-cache");                                   // HTTP/1.0
?&gt;

With just a random number:

&lt;? 
	$lower = 1;
	$upper = 7;
	$random_number = mt_rand($lower, $upper);
	$image = "$random_number.jpg";

	header("Location: $image");
?&gt;

With this one, you just number all of the images you want rotated.

:ninja: sorry but i said post no code :p its cool anyway will work on it see what happens post any errors

Link to comment
Share on other sites

  • 0

So you don't really want a rotator, you want a slideshow. In that case, use Javascript - PHP is server side and every time the image changes would require another request for the page from the server.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.