<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: fast random image php</title>
	<atom:link href="http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/</link>
	<description></description>
	<pubDate>Thu, 20 Nov 2008 21:33:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Alegis</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-7001</link>
		<dc:creator>Alegis</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-7001</guid>
		<description>Thanks, I needed this
</description>
		<content:encoded><![CDATA[<p>Thanks, I needed this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-7000</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-7000</guid>
		<description>Is there a way to MAKE the same random number appear 2 times on the same page?  I would like to generate random b&#038;w pictures at the top (numbered 1-5bw.gif) and I also have the same images in color (numbered 1-5color.gif)  When you mouseover the b&#038;w images, the colored one appears.  Right now, the random numbers generated are different, so it changes the picture, heh.  Is there a simple way to do this...say, &#36;rand1 == &#36;rand2 or something?  Thanks!</description>
		<content:encoded><![CDATA[<p>Is there a way to MAKE the same random number appear 2 times on the same page?  I would like to generate random b&#038;w pictures at the top (numbered 1-5bw.gif) and I also have the same images in color (numbered 1-5color.gif)  When you mouseover the b&#038;w images, the colored one appears.  Right now, the random numbers generated are different, so it changes the picture, heh.  Is there a simple way to do this&#8230;say, &#36;rand1 == &#36;rand2 or something?  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gameboy</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6999</link>
		<dc:creator>Gameboy</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6999</guid>
		<description>Here's a random output function that I use on my site. You can define HTML strings that can be anything, just an image, or text, or a link. I like this function because you can easily alter it, because of the automatically incrementing array item declaration that PHP offers. AND, you can make items conditional, for example you can put some items in "if" constructs that use the date and display the item only before a certain date, or on a particular weekday.

&#36;banarr[]='enter complete html here - image, text, link.. anything';
&#36;banarr[]='and another one';
if (date('l')=='Tuesday') {
    &#36;banarr[]='this one may show on tuesdays only';
}
&#36;banarr[]='repeat the empty banarr[] declaration for each new item';
echo &#36;banarr[rand(0,sizeof(&#36;banarr)-1)];


The last line produces the output - all in just one line of code. You may want to make the above into a function, where you have the array as a parameter, or simply to call the function on several places on your site.</description>
		<content:encoded><![CDATA[<p>Here&#039;s a random output function that I use on my site. You can define HTML strings that can be anything, just an image, or text, or a link. I like this function because you can easily alter it, because of the automatically incrementing array item declaration that PHP offers. AND, you can make items conditional, for example you can put some items in &#034;if&#034; constructs that use the date and display the item only before a certain date, or on a particular weekday.</p>
<p>&#36;banarr[]=&#039;enter complete html here - image, text, link.. anything&#039;;<br />
&#36;banarr[]=&#039;and another one&#039;;<br />
if (date(&#039;l')==&#039;Tuesday&#039;) {<br />
    &#36;banarr[]=&#039;this one may show on tuesdays only&#039;;<br />
}<br />
&#36;banarr[]=&#039;repeat the empty banarr[] declaration for each new item&#039;;<br />
echo &#36;banarr[rand(0,sizeof(&#36;banarr)-1)];</p>
<p>The last line produces the output - all in just one line of code. You may want to make the above into a function, where you have the array as a parameter, or simply to call the function on several places on your site.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cis</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6998</link>
		<dc:creator>Cis</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6998</guid>
		<description>I use that skin on your site. i like it alot. I wish there was a noscroll feature to it though, so that the pattern stayed put and the text scrolled on instead of the image repeating at the bottom.</description>
		<content:encoded><![CDATA[<p>I use that skin on your site. i like it alot. I wish there was a noscroll feature to it though, so that the pattern stayed put and the text scrolled on instead of the image repeating at the bottom.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lynda</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6997</link>
		<dc:creator>Lynda</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6997</guid>
		<description>This is the first time I've used while, endwhile, actually, but I think I'm familiar with all the other loops..hehe.

basically, the first time the script runs into while, it's an IF statement.  IF $rand2 is the same number as $rand, then...

The next line RESETS the $rand2 to a completely new random number..

I'm not positive it will work because, as I said, I've never used while, endwhile before but it seemed the easiest solution - I know other loops could do it too with more code.

So WHILE $rand2 is the same number as $rand (because if we just JUST an if statement, it might pick the same number) it's going to reset $rand2.

Does that make any more sense?  I'm not sure I'm more awake.  hehe.</description>
		<content:encoded><![CDATA[<p>This is the first time I&#039;ve used while, endwhile, actually, but I think I&#039;m familiar with all the other loops..hehe.</p>
<p>basically, the first time the script runs into while, it&#039;s an IF statement.  IF $rand2 is the same number as $rand, then&#8230;</p>
<p>The next line RESETS the $rand2 to a completely new random number..</p>
<p>I&#039;m not positive it will work because, as I said, I&#039;ve never used while, endwhile before but it seemed the easiest solution - I know other loops could do it too with more code.</p>
<p>So WHILE $rand2 is the same number as $rand (because if we just JUST an if statement, it might pick the same number) it&#039;s going to reset $rand2.</p>
<p>Does that make any more sense?  I&#039;m not sure I&#039;m more awake.  hehe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kristine</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6996</link>
		<dc:creator>kristine</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6996</guid>
		<description>That makes sense.  Pick a number, and pick a number, and if they match, try again.
Can you explain the while and endwhile parts of that code for me? (i'm such a newbie php-er, and so I'm totally wanting knowledge!!!)  When you are back up and awake of course :giggle:</description>
		<content:encoded><![CDATA[<p>That makes sense.  Pick a number, and pick a number, and if they match, try again.<br />
Can you explain the while and endwhile parts of that code for me? (i&#039;m such a newbie php-er, and so I&#039;m totally wanting knowledge!!!)  When you are back up and awake of course :giggle:</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Row</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6994</link>
		<dc:creator>Row</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6994</guid>
		<description>Of course if you categorised your Buffy pics you would lose a little of that surprise element :(</description>
		<content:encoded><![CDATA[<p>Of course if you categorised your Buffy pics you would lose a little of that surprise element <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lynda</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6995</link>
		<dc:creator>Lynda</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6995</guid>
		<description>Awesome and very simple, Kristine!  :)   

There are ways to make sure the same number doesn't pop up twice, but I'm so tired that I'm sure what I'm thinking of is too complicated and a far simpler solution can be reached so I'm going to sleep on it before posting it.  LOL.  

It would involve setting a $rand variable to a random number between 1-20, then setting a $rand2 variable also between 1-20, however if $rand == $rand2, it has to pick again...

I'm not positive this would work, but in theory it should:

Set this up after the body tag:

&#60;?php
$rand = rand(1, 20);
$rand2 = rand(1,20);
while ($rand2 == $rand):
   $rand2 = rand(1, 20);
endwhile;
?&#62;

Then echo $rand and $rand2 in the appropriate places.   Again, dunno if it works, but in theory, it will set $rand2 and then while $rand2 is coming up the same number as $rand, it will reset $rand2 to another random variable.</description>
		<content:encoded><![CDATA[<p>Awesome and very simple, Kristine!  <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   </p>
<p>There are ways to make sure the same number doesn&#039;t pop up twice, but I&#039;m so tired that I&#039;m sure what I&#039;m thinking of is too complicated and a far simpler solution can be reached so I&#039;m going to sleep on it before posting it.  LOL.  </p>
<p>It would involve setting a $rand variable to a random number between 1-20, then setting a $rand2 variable also between 1-20, however if $rand == $rand2, it has to pick again&#8230;</p>
<p>I&#039;m not positive this would work, but in theory it should:</p>
<p>Set this up after the body tag:</p>
<p>&lt;?php<br />
$rand = rand(1, 20);<br />
$rand2 = rand(1,20);<br />
while ($rand2 == $rand):<br />
   $rand2 = rand(1, 20);<br />
endwhile;<br />
?&gt;</p>
<p>Then echo $rand and $rand2 in the appropriate places.   Again, dunno if it works, but in theory, it will set $rand2 and then while $rand2 is coming up the same number as $rand, it will reset $rand2 to another random variable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Row</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6993</link>
		<dc:creator>Row</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/16/fast-random-image-php/#comment-6993</guid>
		<description>On my site, I use three different groups of images. What I do is this:

I write an array from 0 to 25, listing the image url, dimensions, and alt text. Then I put this at the bottom:

&lt;h3&gt;srand(time());
$random = (rand(0,9));
$random1 = (rand(10,18));
$random2 = (rand(19,25));&lt;/h3&gt;

Then where I want the pictures to display, I just put &lt;h3&gt;&#60;? echo $photo[$random]; ?&#62; &#60;? echo $photo[$random1]; ?&#62; &#60;? echo $photo[$random2]; ?&#62;&lt;/h3&gt;

It ensures that the three pics are never duplicated, and it also allows me to categorise the photos.</description>
		<content:encoded><![CDATA[<p>On my site, I use three different groups of images. What I do is this:</p>
<p>I write an array from 0 to 25, listing the image url, dimensions, and alt text. Then I put this at the bottom:</p>
<h3>srand(time());<br />
$random = (rand(0,9));<br />
$random1 = (rand(10,18));<br />
$random2 = (rand(19,25));</h3>
<p>Then where I want the pictures to display, I just put<br />
<h3>&lt;? echo $photo[$random]; ?&gt; &lt;? echo $photo[$random1]; ?&gt; &lt;? echo $photo[$random2]; ?&gt;</h3>
<p>It ensures that the three pics are never duplicated, and it also allows me to categorise the photos.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.339 seconds -->
