Jump to content


This topic is now archived and is closed to further replies.


adding speed to image rotation

Recommended Posts

Please help i am trying to get the images to display at a fast rate randomly thank you.

I will add a button to stop the fast random image and then insert image name to database.

What code syntax do you use to get a random image to randomize fast please help thank you.


srand((float) microtime() * 10000000);






  $rn = array_rand($image);

echo '<a href="'.$image[$rn]['link'].'">';
echo '<img src="'.$image[$rn]['pic'].'">';

Share this post

Link to post
Share on other sites
I think you would be better off using Javascript for this instead of PHP....

Share this post

Link to post
Share on other sites
[!--quoteo(post=352799:date=Mar 8 2006, 11:23 AM:name=Gaia)--][div class=\'quotetop\']QUOTE(Gaia @ Mar 8 2006, 11:23 AM) [snapback]352799[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I think you would be better off using Javascript for this instead of PHP....

please can someone give an example in javascript tp acomplish this random image speed roatating method and a stop button then thank you.

Share this post

Link to post
Share on other sites
I have got the code below to get a pic to roatate at a high speed in javascript thanks.

What i need help in is to get the random pic to stop on the pic buy pressing a button, Then i need to insert that random pic that stoped and put it in the database via that pic name.

Please help thank you.

My random pic code via javasript but needs stopbutton and a insert to my database in php.

What i am trying to do is get the random pic to stop via a button then insert that pic name in my database in php and then i will echo that pic out via php and show the user what pic they chose via the stop button.

Hope someone can help cheers.


<script LANGUAGE="JavaScript">

var interval = 0.1; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("http://javascript.internet.com/img/image-cycler/01.jpg");
image_list[image_index++] = new imageItem("http://javascript.internet.com/img/image-cycler/02.jpg");
image_list[image_index++] = new imageItem("http://javascript.internet.com/img/image-cycler/03.jpg");
image_list[image_index++] = new imageItem("http://javascript.internet.com/img/image-cycler/04.jpg");
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
function get_ImageItemLocation(imageObj) {
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
else {
image_index = (image_index+1) % number_of_image;
var new_image = get_ImageItemLocation(image_list[image_index]);
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
// End -->

<BODY OnLoad="rotateImage('rImage')">

<img name="rImage" src="http://javascript.internet.com/img/image-cycler/01.jpg" width=120 height=90>


what about if someone show me how to add a link to the output of the displaying roatating image so when a user press the pick the database gets the image name inserted anyone please thank you.

To get the image name into the database in php can i do it like this please help thank you.

<?php";$image_location = str_replace("?>", "", $image_location");
mysql_query "INSERT INTO pic('$image_location')":
<input method="post" action"">
<input type="hidden" name"$image_location">
<input type="button" name="submit">


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.