Location: PHPKode > projects > ProjectPress > projectpress/forum/forum.php
<?php 
/**
 * ProjectPress main forum
 *
 * @package ProjectPress
 * @since 2.0
 */

// Starts the session.
session_start();

define('access',true);

include(dirname(dirname(__FILE__)) . '/config.inc.php');
include(PM_DIR . 'pm-includes/global.inc.php');
require(PM_DIR . 'pm-includes/functions.php');
include(PM_DIR . 'pm-includes/header.php');

// Checks if user is logged in; if not redirect to login page.
if($current_user->hasPermission('access_site') != true) { pm_redirect(PM_URI . '/index.php'); }

// Enable for error checking and troubleshooting.
# display_errors();

$sql = "SELECT * FROM ". DB ."forum_question ORDER BY id DESC";
// OREDER BY id DESC is order result by descending 
$result = pmdb::connect()->query($sql);

?>

				<div id="page-title">
					<img src="<?php echo PM_URI; ?>/images/comment.png" alt="" /><h1>Forum</h1>
				</div>

				<div id="middle">
<h2>Forum Topics</h2>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
<td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
</tr>

<?php
while($rows = $result->fetch_object()) { // Start looping table row
$query = pmdb::connect()->query("SELECT COUNT(a_id) FROM ". DB ."forum_answer WHERE question_id = '".$rows->id."'");
$r = $query->fetch_array();
?>
<tr>
<td bgcolor="#FFFFFF"><?php echo $rows->id; ?></td>
<td bgcolor="#FFFFFF"><a href="view_topic.php?id=<?php echo $rows->id; ?>"><?php echo $rows->topic; ?></a><br /></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $rows->view; ?></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $r['COUNT(a_id)']; ?></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $rows->datetime; ?></td>
</tr>

<?php
// Exit looping and close connection 
}
?>

<tr>
<td colspan="5" align="right" bgcolor="#E6E6E6"><a href="<?php echo PM_URI ?>/forum/create_topic.php"><strong>Create New Topic</strong> </a></td>
</tr>
</table>
</div>


<?php

include(PM_DIR . 'pm-includes/footer.php');
Return current item: ProjectPress