Location: PHPKode > projects > MegaBB > msg.php
<link rel="stylesheet" type="text/css" href="default.css" />
<html><head><title>MegaBB</title></head><body>
<div id="container">

<?php
// Connecting to the database again
require("dbconnect.php");
include("include/session.php");
include('template/header.php');
include('template/panel.php');
// This query selects the current thread using the $_GET value.
$sql = mysql_query("SELECT * FROM threads WHERE id = '$_GET[id]'");

// Now we are getting our results and making them an array
while($r = mysql_fetch_array($sql)) {

$src = mysql_fetch_array(mysql_query("SELECT avatar FROM users WHERE username = '$r[author]'"));

$src = "/upload/avatars/".$src['avatar'];

$group = mysql_query("SELECT 'userlevel' FROM 'users' WHERE username = '$r[author]'"); 

// $group = mysql_fetch_array(mysql_query("SELECT 'userlevel' FROM 'users' WHERE username = '$r[author]'"));

// Here is the thread title.
echo "<br>
<table border=\"0\" id=\"threadlist\"><thead><tr><th><small>Posted by</small></th><th><small>$r[title]</small></th></tr></thead>";

// Everything within the two curly brackets can read from the database using $r[]
// We need to convert the UNIX Timestamp entered into the database for when a thread...
// ... is posted into a readable date, using date().
$posted = date("jS M Y h:i",$r[posted]);

// Now this shows the thread with a horizontal rule after it.
echo "
<tr>
<td id='msginfo'>
<a href=\"userinfo.php?user=$r[author]\">$r[author]</a><br>$group<br><img id='avatar' src='$src' /></td>
<td id='message'>$r[message]</td>
</tr>
<tr>
<td id='msgfoot'>$posted</td><td id='msgfoot'></td>
</tr></table><br>";

// End of Array
}

// Here we will get it to show the replies
// This query selects the replies from the database where the thread ID matches the thread $_GET value.
$sql = mysql_query("SELECT * FROM replies WHERE thread = '$_GET[id]'");

// Now we are getting our results and making them an array
while($r = mysql_fetch_array($sql)) {

$src = mysql_fetch_array(mysql_query("SELECT avatar FROM users WHERE username = '$r[author]'"));

$src = "/upload/avatars/".$src['avatar'];

// Everything within the two curly brackets can read from the database using $r[]
// We need to convert the UNIX Timestamp entered into the database for when a thread...
// ... is posted into a readable date, using date().
$posted = date("jS M Y h:i",$r[posted]);

// Now this shows the thread with a horizontal rule after it.
echo "<table border=\"0\" id=\"threadlist\">
<tr><th><small>Posted by</small></th><th><small></small></th></tr><tr><small><td id='msginfo'>
<a href=\"userinfo.php?user=$r[author]\">$r[author]</a><br><br><img id='avatar' src='$src' /></td><td id='message'>$r[message]</td></small></tr>
<tr><td id='msgfoot'>$posted</td><td id='msgfoot'></td></tr></table><br>";

// End of Array
}
?><?php
include('template/newreply.php');
include('template/onusers.php');
// Here's a link that will allow you to go back to the index
echo "<a href='index.php'>Go Back...</a>";
?></div></body></html>
Return current item: MegaBB