Simple Machines Community Forum

General Community => Scripting Help => Topic started by: mindazor on January 12, 2020, 06:27:24 AM

Title: How To Make Random Header Images
Post by: mindazor on January 12, 2020, 06:27:24 AM
hallo evry one I nead a Code How to make Random Header Background Images?

Like this one: forum (http://"http://zaxo.at/index.php?action=forum;theme=22")
Title: Re: How To Make Random Header Images
Post by: Looking on January 12, 2020, 09:45:31 AM
There are many ways to do this but it is more than the code, you will need to implement it in theme properly but in any case you could use PHP to do a random pick between numbers and then put the class in relevant place like:

$random=rand(1,3);
$headercss="cssclass";
if($random==2){$headercss="cssclass2";}
if($random==3){$headercss="cssclass3";}
Title: Re: How To Make Random Header Images
Post by: Sir Osis of Liver on January 12, 2020, 11:11:51 PM
Can also do it like this -



$pic = rand(1,5);

echo '
<img src="',$settings['images_url'],'/img/topr', $pic ,'.jpg" alt="" />';



Where images are topr1.jpg, topr2.jpg, etc.