{"id":13,"date":"2008-08-15T20:57:43","date_gmt":"2008-08-16T04:57:43","guid":{"rendered":"http:\/\/kevware.wordpress.com\/?p=32"},"modified":"2008-08-15T20:57:43","modified_gmt":"2008-08-16T04:57:43","slug":"php-code-share-random-part-2","status":"publish","type":"post","link":"https:\/\/www.kevware.com\/geek\/php-code-share-random-part-2\/","title":{"rendered":"PHP Code Share &#8211; Random, part 2"},"content":{"rendered":"<p>Before I forget again I want to throw in the disclaimer that I am not a developer and have just found some pretty good scripts to use for my own site purposes.\u00a0 I make no claims about their security or anything else.\u00a0 So if for some reason you use any of this code and hackers use your website to get into Dubya&#8217;s personal White House email, don&#8217;t point the feds this way when they come knockin&#8217; at your door. LOL<\/p>\n<p>Okay with that out of the way, here is another random image php script I use.\u00a0 It&#8217;s also pretty simple, and could easily be swapped out for the last one I posted.\u00a0 But I always think options are a good thing.\u00a0 Just take a look at any of my over 20 pairs of shoes (mostly Skechers).\u00a0 Here is the code:<br \/>\n&lt;?php<\/p>\n<p>\/*<\/p>\n<p>* Name your images 1.jpg, 2.jpg etc.<\/p>\n<p>*<\/p>\n<p>* Add this line to your page where you want the images to<\/p>\n<p>* appear: &lt;?php include &#8220;randomimage.php&#8221;; ?&gt;<\/p>\n<p>*\/<\/p>\n<p>\/\/ Change this to the total number of images in the folder<\/p>\n<p>$total = &#8220;7&#8221;;<\/p>\n<p>\/\/ Change to the type of files to use eg. .jpg or .gif<\/p>\n<p>$file_type = &#8220;.jpg&#8221;;<\/p>\n<p>\/\/ Change to the location of the folder containing the images<\/p>\n<p>$image_folder = &#8220;images\/random&#8221;;<\/p>\n<p>\/\/ You do not need to edit below this line<\/p>\n<p>$start = &#8220;1&#8221;;<\/p>\n<p>$random = mt_rand($start, $total);<\/p>\n<p>$image_name = $random . $file_type;<\/p>\n<p>echo &#8220;&lt;img src=&#8221;$image_folder\/$image_name&#8221; alt=&#8221;alt text here&#8221; style=&#8221;border: #cccccc 1px solid&#8221; \/&gt;&#8221;;<\/p>\n<p>?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before I forget again I want to throw in the disclaimer that I am not a developer and have just found some pretty good scripts to use for my own site purposes.\u00a0 I make no claims about their security or anything else.\u00a0 So if for some reason you use any of this code and hackers &#8230; <span class=\"more\"><a class=\"more-link\" href=\"https:\/\/www.kevware.com\/geek\/php-code-share-random-part-2\/\">[Read more&#8230;]<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-admin","4":"post-13","6":"format-standard","7":"category-php-code"},"_links":{"self":[{"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":0,"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kevware.com\/geek\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}