<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1031870" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1031870</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-random-result-database#comment-1186828</link>
    <description> &lt;p&gt;Awesome.  I tried many variants of how to combine the elements of code #1 into code #2 but I guess I didn&#039;t hit that exact string.  Thanks you so much!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;&lt;strong&gt;Greg K wrote:&lt;/strong&gt;  PS. Not related, but I was wondering,  what code/calculations are you using to generate the graph to show how recent someone is?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Click here to see my long winded explanation.&lt;br /&gt;
&lt;a href=&quot;http://www.pstvalumni.com/forum/viewtopic.php?p=1348#1348&quot; class=&quot;bb-url&quot;&gt;http://www.pstvalumni.com/forum/viewtopic.php?p=1348#1348&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;which involves the following code to make it work (which somebody here probably helped me with years ago)&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;while(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] == &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= \&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Unknown\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 30)&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;New\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 180)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;10\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 360)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;9\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 540)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;8\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 720)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;7\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 900)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;6\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 1080)&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;5\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 1260)&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;4\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 1440)&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;3\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 1620)&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;2\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;days_stale&#039;] &amp;lt; 1800)&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;1\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$stalerating&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;0\&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Thu, 01 Dec 2005 14:21:37 +0000</pubDate>
 <dc:creator>fifeclub</dc:creator>
 <guid isPermaLink="false">comment 1186828 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-random-result-database#comment-1186799</link>
    <description> &lt;p&gt;Just to make sure I am understanding you correctly, the bottom code sample you give is what you used to get the bottom table on the page. If so you still need to add the random field and the sort option:&lt;br /&gt;
 &lt;code&gt; SELECT *,(TO_DAYS(NOW())-TO_DAYS(lastupdated)) AS days_stale, RAND() AS sorter FROM alumni ORDER BY sorter LIMIT 10&lt;/code&gt;&#039;&lt;/p&gt;
&lt;p&gt; That should work.&lt;/p&gt;
&lt;p&gt; -Greg&lt;/p&gt;
&lt;p&gt; PS. Not related, but I was wondering,  what code/calculations are you using to generate the graph to show how recent someone is?&lt;/p&gt;
 </description>
     <pubDate>Thu, 01 Dec 2005 04:44:12 +0000</pubDate>
 <dc:creator>Greg K</dc:creator>
 <guid isPermaLink="false">comment 1186799 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-random-result-database#comment-1186795</link>
    <description> &lt;p&gt;Thanks again.  The code you gave worked perfectly in the simplified example code I posted.  But I&#039;m having unexpected trouble making it work with additional variables.&lt;/p&gt;
&lt;p&gt;The good code that randomly picks 10 entries from the database is&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;*,&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;RAND&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;() AS &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;sorter FROM alumni ORDER BY sorter&amp;nbsp; LIMIT 10&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt; &lt;/p&gt;
&lt;p&gt;The code I&#039;m trying to make that work with is&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;*, (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;TO_DAYS&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;NOW&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;())-&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;TO_DAYS&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;lastupdated&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)) AS &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;days_stale FROM alumni LIMIT 10&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt; &lt;/p&gt;
&lt;p&gt;What this code does is determine how many days old an entry is, which is displayed in the results.  If you need more of the code I can post it but I try to keep my posts very simple.&lt;/p&gt;
&lt;p&gt;Here&#039;s the page I&#039;m testing on.  &lt;a href=&quot;http://www.pstvalumni.com/directory/random.php&quot; class=&quot;bb-url&quot;&gt;http://www.pstvalumni.com/directory/random.php&lt;/a&gt;  As you keep hitting refresh you&#039;ll notice the top section does generate random results each time while the bottom just starts with the first entry.  I need the list on the bottom to be 10 random entries rather than the first 10 in order.&lt;/p&gt;
&lt;p&gt;Thanks again in advance.&lt;/p&gt;
 </description>
     <pubDate>Thu, 01 Dec 2005 03:34:34 +0000</pubDate>
 <dc:creator>fifeclub</dc:creator>
 <guid isPermaLink="false">comment 1186795 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-random-result-database#comment-1186687</link>
    <description> &lt;p&gt;Thanks very much.  I&#039;ll try that as soon as I get a chance.  &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Tue, 29 Nov 2005 15:45:20 +0000</pubDate>
 <dc:creator>fifeclub</dc:creator>
 <guid isPermaLink="false">comment 1186687 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-random-result-database#comment-1186684</link>
    <description> &lt;p&gt;You might have to do it this way:&lt;/p&gt;
&lt;p&gt;SELECT *,RAND() AS sorter FROM alumni ORDER BY sorter LIMIT 10&lt;/p&gt;
&lt;p&gt;I just did a test fo this on one of my tables, and it seems to work. Note that if by chance you have a field called &quot;sorter&quot; you will have to change that name above.&lt;/p&gt;
&lt;p&gt;Also, if your table has more than the fields you are requesting, you should modify it to be &lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;SELECT `firstname`,`maidenname`,`lastname`,`classyear`, RAND() AS sorter&lt;br /&gt;FROM alumni&lt;br /&gt;ORDER BY sorter&lt;br /&gt;LIMIT 10&lt;/code&gt;&lt;/div&gt;&#039; so that the least amount of data is returned to PHP.&lt;/p&gt;
 </description>
     <pubDate>Tue, 29 Nov 2005 15:15:34 +0000</pubDate>
 <dc:creator>Greg K</dc:creator>
 <guid isPermaLink="false">comment 1186684 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-random-result-database#comment-1186656</link>
    <description> &lt;p&gt;... order by lastupdated,&lt;strong&gt;RAND()&lt;/strong&gt; ...&lt;/p&gt;
 </description>
     <pubDate>Tue, 29 Nov 2005 07:54:37 +0000</pubDate>
 <dc:creator>Busy</dc:creator>
 <guid isPermaLink="false">comment 1186656 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
