|
|
|
|
![]() ![]() |
Feb 25 2005, 03:48 AM
Post
#1
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 618 Joined: 30-October 04 From: Philippines Member No.: 2,049 |
First, It's really confusing. Do you know any tutorials on Image Manipulation on PHP?
Here's another simple one: 1. Create a 5 image. 2. Rename them to something like: image1.jpg; image2.jpg; and so on... 3. Create your PHP file (rotation.php) 4. Enter the following code: CODE <?php header("content-type: image/jpeg"); readfile("image".mt_rand(1,3).".jpg"); ?> 5. Execute your script. |
|
|
|
Feb 25 2005, 05:56 AM
Post
#2
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 702 Joined: 17-February 05 Member No.: 3,817 |
Could you please a little bit more elaborate. I'm interested in using this script. where do I keep the images and also file path is not mentioned clearly. Please...
|
|
|
|
Feb 25 2005, 06:33 AM
Post
#3
|
|
|
{([Mod])} ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 710 Joined: 30-October 04 From: Texas Member No.: 2,058 |
You save the images in the directory as the rotation is in.
|
|
|
|
Feb 25 2005, 08:00 AM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 618 Joined: 30-October 04 From: Philippines Member No.: 2,049 |
QUOTE(rejected @ Feb 25 2005, 02:33 PM) Yes. Or you can change it... example "images/rotate/ads/image" |
|
|
|
Feb 25 2005, 10:59 PM
Post
#5
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 15 Joined: 25-February 05 From: Somewhere? LOL. Member No.: 3,988 |
Here's an even easier way, if that's too complicated. lol.
CODE <? $show = 2; //change 5 to number of buttons you want to show $button[] = "|-img code here-|"; $button[] = "|-img code here-|"; //and so on srand ((float) microtime() * 10000000); $Keys = array_rand($button, 3); //change 5 to number of buttons you want to show for($K = 0; $K < $show; $K++){ echo "".$button[$Keys[$K]].""; } ?> Just add more lines of $button[] = "|-img code here-|"; to the code to make more images! Hope that helps! |
|
|
|
Feb 26 2005, 10:14 AM
Post
#6
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 618 Joined: 30-October 04 From: Philippines Member No.: 2,049 |
QUOTE(egbakaet @ Feb 26 2005, 06:59 AM) Here's an even easier way, if that's too complicated. lol. CODE <? $show = 2; //change 5 to number of buttons you want to show $button[] = "|-img code here-|"; $button[] = "|-img code here-|"; //and so on srand ((float) microtime() * 10000000); $Keys = array_rand($button, 3); //change 5 to number of buttons you want to show for($K = 0; $K < $show; $K++){ echo "".$button[$Keys[$K]].""; } ?> Just add more lines of $button[] = "|-img code here-|"; to the code to make more images! Hope that helps! It's more difficult! Especially in using Arrays! http://www.trap17.com/forums/index.php?showtopic=7711 |
|
|
|
Feb 26 2005, 04:57 PM
Post
#7
|
|
|
Premium Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 153 Joined: 21-December 04 Member No.: 2,829 |
I got this image rotator:
CODE <?php // Make this the relative path to the images, like "../img" or "random/images/". // If the images are in the same directory, leave it blank. $folder = 'fotos/banner/'; // Space seperated list of extensions, you probably won't have to change this. $exts = 'jpg jpeg png gif'; $files = array(); $i = -1; // Initialize some variables if ('' == $folder) $folder = './'; $handle = opendir($folder); $exts = explode(' ', $exts); while (false !== ($file = readdir($handle))) { foreach($exts as $ext) { // for each extension check the extension if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive $files[] = $file; // it's good ++$i; } } } closedir($handle); // We're not using it anymore mt_srand((double)microtime()*1000000); // seed for PHP < 4.2 $rand = mt_rand(0, $i); // $i was incremented as we went along header('Location: '.$folder.$files[$rand]); // Voila! ?> It's working but I wanted it to make a .jpg file not a .php so I could put it on a forum... do you guys know if I can do it? |
|
|
|
![]() ![]() |
Similar Topics
|