(RESOLVED) call php function every 'x' amount of seconds

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

(RESOLVED) call php function every 'x' amount of seconds

Post by hairytea »

Hi,

Is it possible to call a function every 'x' amount of seconds like javascript's setTimeout("functionToCall()",10000); function??

Thanks Guys :-0
Last edited by hairytea on Wed Feb 24, 2010 9:34 am, edited 1 time in total.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: call php function every 'x' amount of seconds

Post by Darhazer »

You can use tick
But the timing should be implement by you, since you can not specify number of seconds
you can use a while() which tracks time and call functions every x seconds
it hardly depends on what you want to do.
hairytea
Forum Commoner
Posts: 92
Joined: Mon Feb 04, 2008 8:31 am

Re: (RESOLVED) call php function every 'x' amount of seconds

Post by hairytea »

I have made a javascript workaround...

Code: Select all

 
<script type="text/javascript">
<!--
function ranImage() {
    
images1 = new Array();
images1[0]="<img src='images/<?php echo $imageOne; ?>' alt='<?php echo $resort_name; ?>, <?php echo $actual_country; ?>' title='<?php echo $resort_name; ?>, <?php echo $actual_country;?>' border='2' width='500' height='291' />";
 
images1[1]="<img src='images/<?php echo $imageTwo; ?>' alt='<?php echo $resort_name; ?>, <?php echo $actual_country; ?>' title='<?php echo $resort_name; ?>, <?php echo $actual_country;?>' border='2' width='500' height='291' />";
 
images1[2]="<img src='images/<?php echo $imageThree; ?>' alt='<?php echo $resort_name; ?>, <?php echo $actual_country; ?>' title='<?php echo $resort_name; ?>, <?php echo $actual_country;?>' border='2' width='500' height='291' />";
 
images1[3]="<img src='images/<?php echo $imageFour; ?>' alt='<?php echo $resort_name; ?>, <?php echo $actual_country; ?>' title='<?php echo $resort_name; ?>, <?php echo $actual_country;?>' border='2' width='500' height='291' />";
 
images1[4]="<img src='images/<?php echo $imageFive; ?>' alt='<?php echo $resort_name; ?>, <?php echo $actual_country; ?>' title='<?php echo $resort_name; ?>, <?php echo $actual_country;?>' border='2' width='500' height='291' />";
 
 
index1 = Math.floor(Math.random() * images1.length);
 
document.getElementById('piccy').innerHTML = images1[index1];
 
 
setTimeout("ranImage()",4000);
 
}
//-->
</script>
 
Post Reply