<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Content rotation</title>
	<link>http://askmichel.icoder.com/2006/10/30/content-rotation/</link>
	<description>i Code to help you profit!</description>
	<pubDate>Tue,  6 Jan 2009 02:05:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.3</generator>

	<item>
		<title>by: gorky5</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-294</link>
		<pubDate>Wed, 29 Oct 2008 12:36:47 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-294</guid>
					<description>Ah, so simple, yet so elusive. Thanks so much Michel! I'm really grateful for your help with this - it's solved a lot of problems for me.

I'm pretty much a php newbie, with my knowledge limited to hacking around with WordPress themes. I appreciate you sharing your knowledge with others.

Joe</description>
		<content:encoded><![CDATA[<p>Ah, so simple, yet so elusive. Thanks so much Michel! I&#8217;m really grateful for your help with this - it&#8217;s solved a lot of problems for me.</p>
<p>I&#8217;m pretty much a php newbie, with my knowledge limited to hacking around with WordPress themes. I appreciate you sharing your knowledge with others.</p>
<p>Joe
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: michel</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-293</link>
		<pubDate>Tue, 28 Oct 2008 16:56:14 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-293</guid>
					<description>Hi Joe,

Lets suppose you have 365 files named as &lt;code&gt;1.html&lt;/code&gt;, &lt;code&gt;2.html&lt;/code&gt;, ..., &lt;code&gt;180.html&lt;/code&gt;, ..., &lt;code&gt;365.html&lt;/code&gt; . One file per a day of the year. Then you don't need this &lt;code&gt;content-rotation.php&lt;/code&gt; or &lt;code&gt;index.php&lt;/code&gt; files.

You can use this simple php-snippet below to include your numbered html-files into any of your php-pages:

&lt;code&gt;&amp;#60;?php
include ( date(&amp;#34;z&amp;#34;) . &amp;#34;.html&amp;#34; );
?&amp;#62;&lt;/code&gt;

Michel</description>
		<content:encoded><![CDATA[<p>Hi Joe,</p>
<p>Lets suppose you have 365 files named as <code>1.html</code>, <code>2.html</code>, &#8230;, <code>180.html</code>, &#8230;, <code>365.html</code> . One file per a day of the year. Then you don&#8217;t need this <code>content-rotation.php</code> or <code>index.php</code> files.</p>
<p>You can use this simple php-snippet below to include your numbered html-files into any of your php-pages:</p>
<p><code>&lt;?php<br />
include ( date(&quot;z&quot;) . &quot;.html&quot; );<br />
?&gt;</code></p>
<p>Michel
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: gorky5</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-292</link>
		<pubDate>Tue, 28 Oct 2008 16:26:47 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-292</guid>
					<description>Hi Michel. I'm trying to do something similar to Mistephen - content rotation based on the day/week/month of the year. I can do it using ssi files, but they don't cooperate well with php pages.

I've uploaded your index.php, content-rotation.php and some dummy index.html pages to my server, but I can't see how it's choosing the specific filenames based on the date command.

Is there a way to specify that it looks for, say, 1.shtml, 2.html and so on, if that number is the day of the year? If so, would you be able to publish the entire code that I'll need? (obviously the 1.html or 1.jpg etc files are up to me to create!)

Many thanks in advance. I've spent hours looking for a solution and am more confused than ever!</description>
		<content:encoded><![CDATA[<p>Hi Michel. I&#8217;m trying to do something similar to Mistephen - content rotation based on the day/week/month of the year. I can do it using ssi files, but they don&#8217;t cooperate well with php pages.</p>
<p>I&#8217;ve uploaded your index.php, content-rotation.php and some dummy index.html pages to my server, but I can&#8217;t see how it&#8217;s choosing the specific filenames based on the date command.</p>
<p>Is there a way to specify that it looks for, say, 1.shtml, 2.html and so on, if that number is the day of the year? If so, would you be able to publish the entire code that I&#8217;ll need? (obviously the 1.html or 1.jpg etc files are up to me to create!)</p>
<p>Many thanks in advance. I&#8217;ve spent hours looking for a solution and am more confused than ever!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: michel</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-291</link>
		<pubDate>Tue, 21 Oct 2008 12:54:59 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-291</guid>
					<description>Hi Stephen,

Yes, this is possible.
The original script is designed to show HTML-snippets in random order.

In order to show one &quot;tip&quot; per day you can use the php-function date()
to get the number of a day in the year: &lt;code&gt;date(&amp;#34;z&amp;#34;)&lt;/code&gt;
So the php-script would look like this:

&lt;code&gt;&amp;#60;?php
$content_rotation_list = array(
 &amp;#34;page1.html&amp;#34;,
 &amp;#34;page2.html&amp;#34;,
 &amp;#34;page3.html&amp;#34;,
 &amp;#34;page4.html&amp;#34;,
 . . .
);
$tip_idx = date(&amp;#34;z&amp;#34;) % count($content_rotation_list);
include( $content_rotation_list[ $tip_idx ] );
?&amp;#62;&lt;/code&gt;

Hope this help.

Michel</description>
		<content:encoded><![CDATA[<p>Hi Stephen,</p>
<p>Yes, this is possible.<br />
The original script is designed to show HTML-snippets in random order.</p>
<p>In order to show one &#8220;tip&#8221; per day you can use the php-function date()<br />
to get the number of a day in the year: <code>date(&quot;z&quot;)</code><br />
So the php-script would look like this:</p>
<p><code>&lt;?php<br />
$content_rotation_list = array(<br />
 &quot;page1.html&quot;,<br />
 &quot;page2.html&quot;,<br />
 &quot;page3.html&quot;,<br />
 &quot;page4.html&quot;,<br />
 . . .<br />
);<br />
$tip_idx = date(&quot;z&quot;) % count($content_rotation_list);<br />
include( $content_rotation_list[ $tip_idx ] );<br />
?&gt;</code></p>
<p>Hope this help.</p>
<p>Michel
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: mistephen</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-286</link>
		<pubDate>Thu, 09 Oct 2008 15:58:16 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-286</guid>
					<description>Michael,

What I am trying to do is a &quot;tip of the day.&quot; As I see it I can do this without a database by calling a php script to pull up the html content (and use seperate html files for each tip,) and (in the same script??) use the sequential array modifications you show above so they don't come up randomly, plus (in the same script??) use time() fuction to rotate the html files daily. I would also like to place this code in its own file and call in from my home page. Is all that possible, or an I going down the wrong road?

Stephen</description>
		<content:encoded><![CDATA[<p>Michael,</p>
<p>What I am trying to do is a &#8220;tip of the day.&#8221; As I see it I can do this without a database by calling a php script to pull up the html content (and use seperate html files for each tip,) and (in the same script??) use the sequential array modifications you show above so they don&#8217;t come up randomly, plus (in the same script??) use time() fuction to rotate the html files daily. I would also like to place this code in its own file and call in from my home page. Is all that possible, or an I going down the wrong road?</p>
<p>Stephen
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: dcarlson007</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-284</link>
		<pubDate>Tue, 02 Sep 2008 00:40:27 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-284</guid>
					<description>Michael,

I'm very interested in your content rotation script - I really need to make it work.

Based on your example, it seems each of my rotating content blocks must be placed on a separate .PHP page - is that correct? If this is true, then it seems logical to assume that I'll have to rotate each of the content blocks into a frame - this is not ideal.

So here's my question: Do I need a to place each content block on a separate page? I just need to accomplish either of two things: 1) either rotate each block each time a visitor revisits or refreshes their browser, or 2) auto-rotate each block on, say, 2-hour intervals.

Are my assumptions correct?

Please advise at your earliest opportunity.

Thanks much.

Doug C.</description>
		<content:encoded><![CDATA[<p>Michael,</p>
<p>I&#8217;m very interested in your content rotation script - I really need to make it work.</p>
<p>Based on your example, it seems each of my rotating content blocks must be placed on a separate .PHP page - is that correct? If this is true, then it seems logical to assume that I&#8217;ll have to rotate each of the content blocks into a frame - this is not ideal.</p>
<p>So here&#8217;s my question: Do I need a to place each content block on a separate page? I just need to accomplish either of two things: 1) either rotate each block each time a visitor revisits or refreshes their browser, or 2) auto-rotate each block on, say, 2-hour intervals.</p>
<p>Are my assumptions correct?</p>
<p>Please advise at your earliest opportunity.</p>
<p>Thanks much.</p>
<p>Doug C.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: michel</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-269</link>
		<pubDate>Fri, 06 Jun 2008 07:48:09 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-269</guid>
					<description>Hi Koolajay,

When you use a database with server scripts
you need to &lt;em&gt;select&lt;/em&gt; your content by some criteria.
This absolutely depends on your database structure/data.

You can use system timer to toggle the selection criteria by specified time.
For example, the &lt;code&gt;time()&lt;/code&gt; PHP-function gets current &lt;code&gt;timestamp&lt;/code&gt; &lt;small&gt;(the number of seconds since January 1, 1970)&lt;/small&gt;. So the &lt;code&gt;time() / 3600;&lt;/code&gt; sentence produces the number of hours since January 1, 1970. And &lt;code&gt;time() / 7200;&lt;/code&gt; provides you with a unique number every 2 hours.

Lets suppose you have 17 database records with html-code to rotate them on your page. And each of these records has an ordering number. So the PHP code-snippet below could select a new record every 2 hours:
&lt;div style=&quot;border:1px solid silver;padding:1ex;backgroubd-color:#f9f9f9;&quot;&gt;&lt;code&gt;&amp;#60;?php
. . .
$timeFrame = 2; &lt;span style=&quot;color:gray;&quot;&gt;// 2 hours to rotate&lt;/span&gt;
$numberOfRecords = 17;
$selectNumber = (time() / (3600 * $timeFrame)) % $numberOfRecords +1;
$sqlQuery = &amp;#34;SELECT &lt;em&gt;code&lt;/em&gt; FROM &lt;em&gt;table&lt;/em&gt; WHERE &lt;em&gt;num&lt;/em&gt;=$selectNumber&amp;#34;;
if ($sqlResult = mysql_query($sqlQuery)) {
&amp;#160;if ($rec = mysql_fetch_assoc($sqlResult)) {
&amp;#160;&amp;#160;print $rec[&amp;#34;&lt;em&gt;code&lt;/em&gt;&amp;#34;]
&amp;#160;}
}
. . .
?&amp;#62;&lt;/code&gt;&lt;/div&gt;

Hope this helps.
Michel</description>
		<content:encoded><![CDATA[<p>Hi Koolajay,</p>
<p>When you use a database with server scripts<br />
you need to <em>select</em> your content by some criteria.<br />
This absolutely depends on your database structure/data.</p>
<p>You can use system timer to toggle the selection criteria by specified time.<br />
For example, the <code>time()</code> PHP-function gets current <code>timestamp</code> <small>(the number of seconds since January 1, 1970)</small>. So the <code>time() / 3600;</code> sentence produces the number of hours since January 1, 1970. And <code>time() / 7200;</code> provides you with a unique number every 2 hours.</p>
<p>Lets suppose you have 17 database records with html-code to rotate them on your page. And each of these records has an ordering number. So the PHP code-snippet below could select a new record every 2 hours:</p>
<div style="border:1px solid silver;padding:1ex;backgroubd-color:#f9f9f9;"><code>&lt;?php<br />
. . .<br />
$timeFrame = 2; <span style="color:gray;">// 2 hours to rotate</span><br />
$numberOfRecords = 17;<br />
$selectNumber = (time() / (3600 * $timeFrame)) % $numberOfRecords +1;<br />
$sqlQuery = &quot;SELECT <em>code</em> FROM <em>table</em> WHERE <em>num</em>=$selectNumber&quot;;<br />
if ($sqlResult = mysql_query($sqlQuery)) {<br />
&nbsp;if ($rec = mysql_fetch_assoc($sqlResult)) {<br />
&nbsp;&nbsp;print $rec[&quot;<em>code</em>&quot;]<br />
&nbsp;}<br />
}<br />
. . .<br />
?&gt;</code></div>
<p>Hope this helps.<br />
Michel
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: koolajay</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-266</link>
		<pubDate>Tue, 03 Jun 2008 09:45:52 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-266</guid>
					<description>Hi Michel ,
 Thanks for the script . 

 How can i pull values from database for rotation ?
 i want to rotate html code , 
 how can i rotate html code after specified time ( 2 hours etc .) ?
Please reply .</description>
		<content:encoded><![CDATA[<p>Hi Michel ,<br />
 Thanks for the script . </p>
<p> How can i pull values from database for rotation ?<br />
 i want to rotate html code ,<br />
 how can i rotate html code after specified time ( 2 hours etc .) ?<br />
Please reply .
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: michel</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-264</link>
		<pubDate>Fri, 30 May 2008 10:59:39 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-264</guid>
					<description>Just add &lt;code&gt;&amp;#60;meta&amp;#62;&lt;/code&gt; tag into the head of your web-page to reload the page every X seconds.
The code below automatically reloads the page every 15 seconds:
&lt;div style=&quot;background-color:#f9f9f9;border:1px solid silver;padding:1ex;&quot;&gt;&lt;code&gt;&amp;#60;html&amp;#62;
&amp;#60;head&amp;#62;
&lt;span style=&quot;background-color:yellow;&quot;&gt;&amp;#60;meta http-equiv=&amp;#34;refresh&amp;#34; content=&amp;#34;&lt;span style=&quot;color:brown;&quot;&gt;&lt;b&gt;15&lt;/b&gt;&lt;/span&gt;&amp;#34;&amp;#62;&lt;/span&gt;
&amp;#60;/head&amp;#62;
&amp;#60;body&amp;#62;
. . . Content of your page . . .&lt;/code&gt;&lt;/div&gt;</description>
		<content:encoded><![CDATA[<p>Just add <code>&lt;meta&gt;</code> tag into the head of your web-page to reload the page every X seconds.<br />
The code below automatically reloads the page every 15 seconds:</p>
<div style="background-color:#f9f9f9;border:1px solid silver;padding:1ex;"><code>&lt;html&gt;<br />
&lt;head&gt;<br />
<span style="background-color:yellow;">&lt;meta http-equiv=&quot;refresh&quot; content=&quot;<span style="color:brown;"><b>15</b></span>&quot;&gt;</span><br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
. . . Content of your page . . .</code></div>
]]></content:encoded>
				</item>
	<item>
		<title>by: ekwamba</title>
		<link>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-263</link>
		<pubDate>Fri, 30 May 2008 10:23:00 +0000</pubDate>
		<guid>http://askmichel.icoder.com/2006/10/30/content-rotation/#comment-263</guid>
					<description>hi guys,
i need the rotation to be automatic after X seconds, as opposed to having a button to reload, what would the code be like?</description>
		<content:encoded><![CDATA[<p>hi guys,<br />
i need the rotation to be automatic after X seconds, as opposed to having a button to reload, what would the code be like?
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
