Welcome Guest ( Log In | Register )




                Web Hosting Guide

 
Reply to this topicNew Topic
Coppermine Random Image Script
soleimanian
post Mar 27 2005, 04:56 PM
Post #1


End Of Computer
Group Icon

Group: Members
Posts: 346
Joined: 1-September 04
From: .:: MARS ::.
Member No.: 28


hi
i need a script to display random image of coppermine on my index
Go to the top of the page
 
+Quote Post
vizskywalker
post Mar 28 2005, 04:30 PM
Post #2


Techno-Necromancer
Group Icon

Group: Members
Posts: 1,018
Joined: 13-January 05
From: The Net
Member No.: 2,127


If you have the ability to use PHP, it is easy to make a random image script. Give each picture the same name but with a number at the end of it (make foo.bar foo1.bar footype.bar foo2.bar). Then stick the following code anywhere in the page and make sure the page is a .php type.(The instructions are in the comments).
CODE
<?php
$min = 1; //The first number one of your images has
$max = 10; //The highest number you image has
$number = rand($min, $max);
$url = "http://www.foo.bar/images/foo" . $number . ".bar"; //change the url to your url //for the image split the url into two parts by separating in between the image name and //extension
echo "<img src='$url'>";
?>


That ought to do it.
Go to the top of the page
 
+Quote Post
dungsport
post Mar 29 2005, 01:23 AM
Post #3


Member - Active Contributor
Group Icon

Group: Members
Posts: 93
Joined: 21-March 05
Member No.: 3,136


Here, another way if you'd like to use javascript on your page.

QUOTE
The steps involved in randomly displaying an image from a set are very similar to those used for displaying random text strings.

1. Initializing an array
2. Storing the image file names in that array
3. Finding the length of this array
4. Using the Math.random() to generate a random number
5. Using the randomly generated number as index for retrieving an image file name from the array.
6. Displaying the image.

var img_name = new Array("purple.gif", "red.gif",
"blue.gif", "yellow.gif", "green.gif", "pink.gif");

var l = img_name.length;

var rnd_no = Math.round((l-1)*Math.random());

document.r_img.src = img_name[rnd_no];

<IMG SRC="blank.gif" WIDTH="100" HEIGHT="50"
NAME="r_img" ALT="Random image">


They are just a simple one, you could find a lot more on the net through Google.

This matter could also be done in Flash which is flashier but not really easy to do. Tutorial of how to do it can be found through search engines too. Check out www.flashkit.com if you are serious to Flash.
Go to the top of the page
 
+Quote Post
vizskywalker
post Mar 29 2005, 01:52 AM
Post #4


Techno-Necromancer
Group Icon

Group: Members
Posts: 1,018
Joined: 13-January 05
From: The Net
Member No.: 2,127


If you want to use php instead of javascript (and I'm not saying either's better), but want the javascript ability to have totally different names, you can use this code:
CODE
<?php
$location = "http://blah.blah.foo/foobar"; //this should be the folder containing the //images if they are in separate folders, ignore this line and make the full location of the //images the replacement for pic#.ext in the next line
$pictures = ("pic1.ext", "pic2.ext", "pic3.ext"); //make pic#.ext the name of one of your //images no rules as to format of the name this time
$maxnum = count($pictures);
$randnum = rand(0, maxnum-1);
echo "<img src='$pictures[$randnum]'>";
?>
Go to the top of the page
 
+Quote Post
soleimanian
post Mar 31 2005, 04:15 PM
Post #5


End Of Computer
Group Icon

Group: Members
Posts: 346
Joined: 1-September 04
From: .:: MARS ::.
Member No.: 28


thanks
but i need a script to show random pictures from coppermine database like IPB Portal that use cookies,username and password field and ...
Go to the top of the page
 
+Quote Post
iGuest
post May 2 2008, 12:32 PM
Post #6


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869


i want do the randomly change image without the random() function so how can i do
Coppermine Random Image Script


This is my code . So I want the code which will work without random function.
Go to the top of the page
 
+Quote Post
iGuest
post May 2 2008, 12:36 PM
Post #7


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869


i want the code without random() function.
Coppermine Random Image Script

I m using this code for randomly change the image .






-question by Ravi Jadaun
Go to the top of the page
 
+Quote Post

Reply to this topicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   11 sxyloverboy 5,948 Yesterday, 06:54 AM
Last post by: parveen029
No New Posts  
4 PHP
8 bluefish 3,131 16th March 2010 - 02:01 PM
Last post by: iG-op
No New Posts   11 szupie 3,842 23rd February 2010 - 10:22 PM
Last post by: HannahI
No New Posts   1 oval 1,699 21st February 2010 - 10:53 AM
Last post by: iG-James
No New Posts 7 Niru 4,454 20th February 2010 - 07:04 AM
Last post by: iG-suresh
No New Posts   10 mastercomputers 365 19th February 2010 - 07:42 AM
Last post by: Quatrux
No new   19 Feelay 9,186 18th February 2010 - 08:47 AM
Last post by: iG-Tsholofelo
No New Posts   7 Eggie 161 15th February 2010 - 10:34 PM
Last post by: Nelson Blogs
No New Posts   10 Eggie 8,445 10th February 2010 - 06:47 AM
Last post by: iG-
No New Posts   6 Skepticus 188 7th February 2010 - 02:16 AM
Last post by: 8ennett
No New Posts   0 8ennett 70 30th January 2010 - 11:10 PM
Last post by: 8ennett
No new   25 JohnNitro 15,378 26th January 2010 - 11:30 AM
Last post by: iG-mdshare
No New Posts   6 shiv 4,402 14th January 2010 - 02:47 PM
Last post by: iG-Johnathan
No New Posts   15 sendto 15,309 26th December 2009 - 07:16 AM
Last post by: iG-
No New Posts   3 wutske 1,200 18th December 2009 - 07:36 AM
Last post by: iG-anil kumar


Web Hosting Powered by ComputingHost.com.
HONESTY ROCKS! truth rules.
Creative Commons License