<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Random Mugger On Crazybobbles</title>
	<atom:link href="http://www.crazybobbles.org/2005/03/17/random-mugger-on-crazybobbles/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crazybobbles.org/2005/03/17/random-mugger-on-crazybobbles/</link>
	<description>photos + music + geekery - mind games</description>
	<lastBuildDate>Mon, 30 May 2011 17:26:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: Alex</title>
		<link>http://www.crazybobbles.org/2005/03/17/random-mugger-on-crazybobbles/comment-page-1/#comment-34</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Sat, 19 Mar 2005 14:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazybobbles.org/2005/03/17/random-mugger-on-crazybobbles/#comment-34</guid>
		<description>Think I&#039;ve worked this out :D

I&#039;ve done a more simple way where instead of inserting the new random mug into the table, you could just have one entry and it updates every week.

I&#039;ve got the code here but just check that the fields and table names are correct coz I was testing it out on one of my databases and may have made a mistake when changing it back to your table names...



$query = &quot;SELECT id, pid,timestamp FROM randompic&quot;;
$result = mysql_query($query) or die(&#039;Query failed: &#039; . mysql_error());
$line = mysql_fetch_array($result,MYSQL_ASSOC);

$id = $line[&#039;id&#039;];
$randompic = $line[&#039;pid&#039;];
$lateststamp = $line[&#039;timestamp&#039;];
$daysleft = ceil((($lateststamp+604800)-time())/86400);

if((time()-604800)&gt;$lateststamp){

$query = &quot;SELECT pid FROM cpg132_pictures ORDER BY RAND() LIMIT 1&quot;;
$result = mysql_query($query) or die(&#039;Query failed: &#039; . mysql_error());
$wee = mysql_fetch_array($result,MYSQL_ASSOC);

$newrandompic = $wee[&#039;pid&#039;];
$newstamp=$lateststamp+604800;

$query = &quot;UPDATE randompic SET pid=&#039;$newrandompic&#039;, timestamp=&#039;$newstamp&#039; WHERE id=$id&quot;;
$result = mysql_query($query) or die(&#039;Query failed: &#039; . mysql_error());
}

$query = &quot;SELECT cpg132_pictures.id, cpg132_pictures.filename, randompic.pid FROM cpg132_pictures, randompic WHERE cpg132_pictures.id=randompic.pid LIMIT 1&quot;;
$result = mysql_query($query) or die(&#039;Query failed: &#039; . mysql_error());
$poo = mysql_fetch_array($result,MYSQL_ASSOC);



...then echo all your stuff out. :D</description>
		<content:encoded><![CDATA[<p>Think I&#8217;ve worked this out <img src='http://www.crazybobbles.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>I&#8217;ve done a more simple way where instead of inserting the new random mug into the table, you could just have one entry and it updates every week.</p>
<p>I&#8217;ve got the code here but just check that the fields and table names are correct coz I was testing it out on one of my databases and may have made a mistake when changing it back to your table names&#8230;</p>
<p>$query = &#8220;SELECT id, pid,timestamp FROM randompic&#8221;;<br />
$result = mysql_query($query) or die(&#8216;Query failed: &#8216; . mysql_error());<br />
$line = mysql_fetch_array($result,MYSQL_ASSOC);</p>
<p>$id = $line['id'];<br />
$randompic = $line['pid'];<br />
$lateststamp = $line['timestamp'];<br />
$daysleft = ceil((($lateststamp+604800)-time())/86400);</p>
<p>if((time()-604800)&gt;$lateststamp){</p>
<p>$query = &#8220;SELECT pid FROM cpg132_pictures ORDER BY RAND() LIMIT 1&#8243;;<br />
$result = mysql_query($query) or die(&#8216;Query failed: &#8216; . mysql_error());<br />
$wee = mysql_fetch_array($result,MYSQL_ASSOC);</p>
<p>$newrandompic = $wee['pid'];<br />
$newstamp=$lateststamp+604800;</p>
<p>$query = &#8220;UPDATE randompic SET pid=&#8217;$newrandompic&#8217;, timestamp=&#8217;$newstamp&#8217; WHERE id=$id&#8221;;<br />
$result = mysql_query($query) or die(&#8216;Query failed: &#8216; . mysql_error());<br />
}</p>
<p>$query = &#8220;SELECT cpg132_pictures.id, cpg132_pictures.filename, randompic.pid FROM cpg132_pictures, randompic WHERE cpg132_pictures.id=randompic.pid LIMIT 1&#8243;;<br />
$result = mysql_query($query) or die(&#8216;Query failed: &#8216; . mysql_error());<br />
$poo = mysql_fetch_array($result,MYSQL_ASSOC);</p>
<p>&#8230;then echo all your stuff out. <img src='http://www.crazybobbles.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

