Jump to content


Photo

adding speed to image rotation


  • Please log in to reply
3 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 March 2006 - 05:09 AM

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); 

  $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'].'">'; 

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 08 March 2006 - 11:23 AM

I think you would be better off using Javascript for this instead of PHP....

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 March 2006 - 05:19 AM

[!--quoteo(post=352799:date=Mar 8 2006, 11:23 AM:name=Gaia)--][div class=\'quotetop\']QUOTE(Gaia @ Mar 8 2006, 11:23 AM) View Post[/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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 March 2006 - 05:52 AM

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.


<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>



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");
if($submit)
{
mysql_query "INSERT INTO pic('$image_location')":
}
?>
<input method="post" action"">
<input type="hidden" name"$image_location">
<input type="button" name="submit">


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users