Re: Random HTML
| From: | Kurth Bemis | Date: | Fri, 17 Nov 2000 18:17:48 +0000 |
| Subject: | Re: Random HTML | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25935@lists.php.net to get a copy of this message | ||
At 01:13 PM 11/17/2000 -0500, Kurth Bemis wrote:
i forgot to add - put the first snippet of code in a inc file and then call it like such
random.image.inc?section=service;
or whatever you have for sections......if you'r only going to use it on one page then you cna dump the first 9 or so lines...
~kurth
At 01:03 PM 11/17/2000 -0500, Richard Bradley wrote: i have one...i use it at jrehomes.com to load a differnt picture each time.. =============================snip=========================== <?php //modify files and such.... if($section=="tvestates"){Kurth Bemis - Network/Systems Administrator, USAExpress.net/Ozone Computer There is no sin except stupidity. -- Oscar Wilde kurth@usaexpress.net | http://www.usaexpress.net/kurth PGP key available - http://www.usaexpress.net/kurth/pgp Fight Weak Encryption! Donate your wasted CPU cycles to Distributed.net (http://www.distributed.net)$filename = 'tvestates.inline.txt';}elseif($section=="sales"){$filename = 'sales.inline.txt';}elseif($section=="service"){$filename = 'service.inline.txt';}else{$filename = 'images.inline.txt';}$use_mt_rand = 1; $inline = 1;/*************************************** ** Open file and read in the contents. ***************************************/$file_array = file($filename);/*************************************** ** Determine which random function to use. ***************************************/if($use_mt_rand == 1){ $randseed = 'mt_srand'; $randfunc = 'mt_rand'; }else{ $randseed = 'srand'; $randfunc = 'rand'; }/*************************************** ** Get a random value. If there is only ** one line, then no need to use random ** functions. ***************************************/if(count($file_array) > 1){ $randseed((double)microtime()*1000000); $randval = $randfunc(0,(count($file_array)-1)); }else{ $randval = 0; }/*************************************** ** If using in inline mode create the ** image tag. If not simply output the ** image. ***************************************/if($inline == 1){ echo $file_array[$randval]; }else{/*************************************** ** Determine the image header type to send. ***************************************/ $extension = substr($file_array[$randval], (strrpos($file_array[$randval], '.')+1)); if($extension == 'tif') $extension = 'tiff'; if($extension == 'jpg') $extension = 'jpeg';header('Content-Type: image/'.$extension); header('Pragma: no-cache'); header('Expires: 0'); readfile(trim($file_array[$randval])); }?> =============================snip=========================== and the contents of images.inline.txt; =============================snip=========================== <img src="images/salescenter.jpg" width="352" height="233" border="0" alt="picture" align="right"> <img src="images/salescenter2.jpg" width="352" height="233" border="0" alt="picture" align="right"> <img src="images/salescenter3.jpg" width="322" height="213" border="0" alt="picture" align="right"> <img src="images/salescenter4.jpg" width="322" height="213" border="0" align="right" alt="picture"> <img src="images/salescenter5.jpg" width="322" height="213" border="0" align="right" alt="picture"> <img src="images/salescenter6.jpg" width="322" height="213" border="0" align="right" alt="picture"> =============================snip=========================== have fun! ~kurthDoes anyone have a script for presenting a different graphic or HTML everytime the page is loaded. either from mysql or PHP functions? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.netKurth Bemis - Network/Systems Administrator, USAExpress.net/Ozone Computer There is no sin except stupidity. -- Oscar Wilde kurth@usaexpress.net | http://www.usaexpress.net/kurth PGP key available - http://www.usaexpress.net/kurth/pgp Fight Weak Encryption! Donate your wasted CPU cycles to Distributed.net (http://www.distributed.net) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net