Jump to content

Archived

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

redarrow

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.

[code]

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

  $image[1]['pic']='/location/of/image1.jpg';
  $image[1]['link']='/location/of/link1.php';

  $image[2]['pic']='/location/of/image2.jpg';
  $image[2]['link']='/location/of/link2.php';

  $image[3]['pic']='/location/of/image3.jpg';
  $image[3]['link']='/location/of/link3.php';

  $image[4]['pic']='/location/of/image4.jpg';
  $image[4]['link']='/location/of/link4.php';

  $image[5]['pic']='/location/of/image5.jpg';
  $image[5]['link']='/location/of/link5.php';

  $rn = array_rand($image);

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

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....
[/quote]

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.


[code]
<HEAD>

<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) {
return(imageObj.image_item.src)
}
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]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
// End -->
</script>
</HEAD>



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



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

[/code]


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.

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

[/code]

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.