Need Fast help with php scripting!

Zoekban

Registered Member
Joined
Apr 23, 2013
Messages
63
Reaction score
15
I've made recently a script for showing random pictures, The thing is that i want the script to show Random picture every specific time , like in 5 minutes, in 15 and in 30,
How can it be done, And what do i need to add to my script to improve the script to be working by random timing?

The script is being used in WordPress with the "allow php in post" plugin.

The script is -


$total = "2";
$file_type = ".jpg";
$image_folder = "(images source)";
$start = "1";


$random = mt_rand($start, $total);


$image_name = $random . $file_type;


echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\ />";


Thanks from ahead, And waiting for a reply and help.
Thank you.

Please post an answer with a source or an explanation, if it's possible, thank you!
 
Use time (). Store its value on the picture change. Check the current value of time () with the old one before changing the image again.

Thats an easy way to do it.
 
There's this thing called Google. I just used it and it gave me 2.7 billion solutions to this question with actual PHP examples.
 
Code:
$minutes = date('i');
if($minutes<=15) {
$total = "2";
}elseif($minutes<=30){
$total = "3";
}
$file_type = ".jpg";
$image_folder = "(images source)";
$start = "1";


$random = mt_rand($start, $total);


$image_name = $random . $file_type;


echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\ />";

Adjust the minutes according to your needs -- 15 ,30 .
 
Back
Top