Skip to content
Index Help & Support Faucet Owners Programming

Random Banner Code ( Single File System ) - PHP ONLY

Posted by freek.in 1 year ago
1 712
Random Banner Code ( Single File System ) - PHP ONLY
Posted 1 year ago, last edited 1 year ago
STEP 1 :- First make a file of anyname.php  ( Make sure anyname.php file starts with <?php and ends on ?> ) STEP 2:- include or require that anyname.php file to the file where you want to display advertisements. STEP 3:- Ad your advert codes as mentioned below in anyname.php file <?php $ad728 = ' <div style="border:1px solid #000;text-align:center;line-height:90px;width:728px;"> Your Ad Code For 728x90 Size - Ad #1 </div> '; $ad728 = ' <div style="border:1px solid #000;text-align:center;line-height:90px;width:728px;"> Your Ad Code For 728x90 Size - Ad #2 </div> '; $ad728 = ' <div style="border:1px solid #000;text-align:center;line-height:90px;width:728px;"> Your Ad Code For 728x90 Size - Ad #3 </div> '; $ad728 = ' <div style="border:1px solid #000;text-align:center;line-height:90px;width:728px;"> Your Ad Code For 728x90 Size - Ad #4 </div> '; ?> STEP 4 :- Use the given code to call codes in random display. <?php require 'anyname.php'; $no728 = count($ad728); $ran728 = rand(0,($no728-1)); echo $ad728; ?> NOW if you want to add 468x60 size codes then do like this. <?php # CODES FOR 728x90 SIZE ARE UNDER THIS LINE # $ad728 = ' <div style="border:1px solid #000;text-align:center;line-height:90px;width:728px;"> Your Ad Code For 728x90 Size - Ad #1 </div> '; $ad728 = ' <div style="border:1px solid #000;text-align:center;line-height:90px;width:728px;"> Your Ad Code For 728x90 Size - Ad #2 </div> '; $ad728 = ' <div style="border:1px solid #000;text-align:center;line-height:90px;width:728px;"> Your Ad Code For 728x90 Size - Ad #3 </div> '; $ad728 = ' <div style="border:1px solid #000;text-align:center;line-height:90px;width:728px;"> Your Ad Code For 728x90 Size - Ad #4 </div> '; # CODES FOR 728x90 SIZE END # # CODES FOR 468x60 SIZE ARE UNDER THIS LINE # $ad468 = ' <div style="border:1px solid #000;text-align:center;line-height:60px;width:468px;"> Your Ad Code For 468x60 Size - Ad #1 </div> '; $ad468 = ' <div style="border:1px solid #000;text-align:center;line-height:60px;width:468px;"> Your Ad Code For 468x60 Size - Ad #2 </div> '; $ad468 = ' <div style="border:1px solid #000;text-align:center;line-height:60px;width:468px;"> Your Ad Code For 468x60 Size - Ad #3 </div> '; $ad468 = ' <div style="border:1px solid #000;text-align:center;line-height:60px;width:468px;"> Your Ad Code For 468x60 Size - Ad #4 </div> '; #CODE FOR 468x60 END # ?> Follow Step 4 for 468x60 now like this  Use this code where you want to display 468x60 size adverts. $no468 = count($ad468); $ran468 = rand(0,($no468-1)); echo $ad468; You can read it carefully , then ad any size in single file just replace the calling code as per size.