Location: PHPKode > projects > ProjectPress > projectpress/forum/view_topic.php
<?php
/**
 * ProjectPress view forum topic
 *
 * @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();

// get value of id that sent from address bar 
$id = $_GET['id'];

$sql = "SELECT * FROM ". DB ."forum_question, ". DB ."members WHERE id='$id' AND q_user = username";
$result = pmdb::connect()->query($sql);

$row_a = $result->fetch_object();
?>

				<div id="page-title">
					<img src="<?php echo PM_URI; ?>/images/comment.png" alt="" /><h1>Forum</h1>
				</div>
				
<div id="middle">
<h2>Topic: <a href="<?php echo PM_URI; ?>/forum/view_topic.php?id=<?php echo $_GET['id']; ?>"><?php echo $row_a->topic; ?></a></h2>
<a href="<?php echo PM_URI ?>/forum/forum.php">Go Back Forum Homepage</a><br /><br />
<table width="504" align="center" border="0" bgcolor="#DDD">
	<tr>
		<td align="left"><strong>Title:</strong> <?php echo $row_a->topic; ?> </td> <td align="right"><strong>Date: </strong><?php echo $row_a->datetime; ?></td>
	</tr>
</table>

<table width="504" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>
<td vAlign="top" class="forum">
	<table width="484" border="0">
		<tr>
			<td width="100%" class="forum-topic"><a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $row_a->q_user;?>"><strong><? echo $row_a->first_name; ?> <?php echo $row_a->last_name; ?></strong></a> <?php echo BBCode::parse($row_a->detail); ?></td>
		</tr>
		<?php if($row_a->signature != '') { ?>
		<tr>
			<td class="forum-signature">
				<div class="avatar">
				<?php echo get_user_avatar($row_a->q_user,$row_a->email); ?>
				</div>
				
				<div class="signature">
				<?php echo clickable_link(nl2br($row_a->signature)); ?>
				</div>
			</td>
		</tr>
		<?php } ?>
	</table>
</td>
</tr>
</table>

<br />
<?php 

$sql2 = "SELECT * FROM ". DB ."forum_answer, ". DB ."members WHERE question_id='$id' AND a_user = username ORDER BY a_id ASC";
$result2 = pmdb::connect()->query($sql2);

while($row_b = $result2->fetch_object()){
?>
<table width="504" align="center" border="0" bgcolor="#C6E2FF">
	<tr>
		<td align="left"><strong>Re:</strong> <?php echo $row_a->topic; ?> </td> <td align="right"><strong>Reply Date: </strong><?php echo $row_b->a_datetime; ?></td>
	</tr>
</table>

<table width="504" border="0" align="center" cellpadding="0" cellspacing="0" class="forum-1">

<tr>
<td vAlign="top" class="forum">
	<table width="484" border="0">
		<tr>
			<td width="100%"><a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $row_b->a_user;?>"><strong><?php echo $row_b->first_name; ?> <?php echo $row_b->last_name; ?></strong></a> <?php echo BBCode::parse($row_b->a_answer); ?></td>
		</tr>
		<tr>
			<td class="forum-topic"><?php if($row_b->a_answer && $row_b->a_user == $_SESSION['username']) echo '<a href="edit_reply.php?a_id='.$row_b->a_id.'">Edit</a> | ';?> <?php if($row_b->a_answer && $row_b->a_user == $_SESSION['username']) echo '<a href="delete.php?a_id='.$row_b->a_id.'">Delete</a>';?></td>
		</tr>
		<?php if($row_b->signature != '') { ?>
		<tr>
			<td class="forum-signature">
				<div class="avatar">
				<?php echo get_user_avatar($row_b->username,$row_b->email); ?>
				</div>
				
				<div class="signature">
				<?php echo clickable_link(nl2br($row_b->signature)); ?>
				</div>
			</td>
		</tr>
		<?php } ?>
	</table>
</td>
</tr>
</table>

<?
}

$sql3 = "SELECT view FROM ". DB ."forum_question WHERE id='$id'";
$result3 = pmdb::connect()->query($sql3);

$row = $result3->fetch_array();
$view  =$rows['view'];

// if have no counter value set counter = 1
if(empty($view)){
$view = 1;
$sql4 = "INSERT INTO ". DB ."forum_question(view) VALUES('$view') WHERE id='$id'";
$result4 = pmdb::connect()->query($sql4);
}

// count more value
$addview = $view+1;
$sql5 = "update ". DB ."forum_question set view='$addview' WHERE id='$id'";
$result5 = pmdb::connect()->query($sql5);
?>
<br />
<table width="484" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="<?php echo PM_URI ?>/forum/reply.php?id=<?php echo $id; ?>">
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<?php if($_GET['id'] != 1) { ?>
<tr>
<td valign="top"><strong>Quick Reply</strong><br />
<textarea class="forminput" name="a_answer" cols="45" rows="3" id="a_answer" style="width:500px"></textarea></td>
</tr>
<tr>
<td><br />
<input name="id" type="hidden" value="<?php echo $id; ?>">
<input type="submit" name="Submit" value="Submit" id="sub_button"> <input type="reset" name="Submit2" value="Reset" id="sub_button"></td>
</tr>
<?php } ?>
</table>
</td>
</form>
</tr>
</table>
</div>

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