| 1 |
<?php
|
| 2 |
/*
|
| 3 |
* This PHP-type block displays a list of the authors and subjects of
|
| 4 |
* the most recent comments in a table.
|
| 5 |
*
|
| 6 |
* $Id: mostrecentcomments.php,v 1.3 2003/08/16 23:02:16 chris Exp $
|
| 7 |
* Author: Chris Johnson / chris@tinpixel.com
|
| 8 |
*/
|
| 9 |
|
| 10 |
/*
|
| 11 |
* The current database query below looks for comments newer than 7 days
|
| 12 |
* (24 hours * 3600 seconds),
|
| 13 |
* orders the results by timestamp (newest first) and limits it to
|
| 14 |
* first 3 found. These values are easily changed.
|
| 15 |
*/
|
| 16 |
|
| 17 |
$result = db_query("Select name, subject, cid, nid
|
| 18 |
From {comments} c, {users} u
|
| 19 |
Where u.uid = c.uid
|
| 20 |
And c.timestamp > (unix_timestamp(now()) - 3600*24*7)
|
| 21 |
Order By c.timestamp Desc
|
| 22 |
Limit 3");
|
| 23 |
|
| 24 |
$header = array(t("Name"), t("Subject")); // table column titles
|
| 25 |
while ($comm = db_fetch_array($result)) {
|
| 26 |
$rows[] = array($comm['name'] , '<a href="node/'. $comm['nid'] .'#' . $comm['cid'] . '/view">'. substr($comm['subject'],0,30) .'</a>');
|
| 27 |
}
|
| 28 |
|
| 29 |
$output .= table($header, $rows);
|
| 30 |
|
| 31 |
return $output;
|