Displaying Top 25 Table Rows by Timestamp
<p>The code below lists the top 25 entries (the variable "site") from a MySQL database by "votes_up" in descending order.  It works great.  Each row has a column called "createddatetime" that is of the following structure: </p>

<p>Type: timestamp
Default: CURRENT_TIMESTAMP</p>

<p>How can I change the code below to show the 25 most recently added entries?  Also, how could I display the timestamp like this: "1 November 2009 3:45 pm Greenwich Mean Time"</p>

<p>Thanks in advance,</p>

<p>John</p>

<pre><code>   mysql_connect("mysqlv8", "username", "password") or die(mysql_error());
    mysql_select_db("sitefeather") or die(mysql_error());

    $result = mysql_query("SHOW TABLES");
    $tables = array();
    while ($row = mysql_fetch_assoc($result)) {
        $tables[] = '`'.$row["Tables_in_sitefeather"].'`';

    }

    //$subQuery = "SELECT site, votes_up FROM ".implode(" UNION ALL SELECT site, votes_up FROM ",$tables);

    $subQueryParts = array();
    foreach($tables as $table)
        $subQueryParts[] = "SELECT site, votes_up FROM $table WHERE LENGTH(site)";
    $subQuery = implode(" UNION ALL ", $subQueryParts);

    // Create one query that gets the data you need
    $sqlStr = "SELECT site, sum(votes_up) sumVotesUp
             FROM (
             ".$subQuery." ) subQuery
               GROUP BY site ORDER BY sum(votes_up) DESC LIMIT 25";
    $result = mysql_query($sqlStr);

    $arr = array(); 
    echo "&lt;table class=\"samples2\"&gt;";
    while ($row = mysql_fetch_assoc($result)) { 
        echo '&lt;tr&gt;';
        echo '&lt;td class="sitename2"&gt;&lt;a href="sitelookup3.php?entry='.urlencode($row["site"]).'&amp;searching=yes&amp;search=search"&gt;'.$row["site"].'&lt;/a&gt;&lt;/td&gt;';
        echo '&lt;td&gt;'.$row["sumVotesUp"].'&lt;/td&gt;';
        echo '&lt;/tr&gt;';
    } 

    echo "&lt;/table&gt;";
</code></pre>
