Trigunflame |
10-16-2003 08:54 PM |
I worked on this for about 15 minutes, lots of stuff could be added/changed/improved/tweaked etc.. but this is a basic of how you would display posts within a topic.
ie. review.php?t=X (Where X = thread number)
Btw: I do recommend using / modifying the CSS tags even if you use your own header/footer.
PHP Code:
<?php
//+----------------------------
// Define Connection Variables
//+----------------------------
$site['name'] = "TF Topic View"; // Site Title
$db['host'] = "localhost"; // Server Host
$db['user'] = "root"; // Connect Username
$db['pass'] = ""; // Connect Password
$db['db'] = "forum"; // Database Name
$db['limit'] = 0; // Show ONLY 1st Post | [0 = Off] [1 = On]
$layout['status'] = 1; // Use Built In Template? [0 = Off] [1 = On]
$layout['bg'] = "#D2D2D2"; // Table BG Color
$layout['row1'] = "#EAEAEA"; // Row Alternate 1
$layout['row2'] = "#F2F2F2"; // Row Alternate 2
//+----------------------------
// Build MySQL Query Class
//+----------------------------
class mysql
{
//---------------------------
// MySQL Initiation Function
//---------------------------
function init ()
{
global $db;
mysql_connect($db['host'],$db['user'],$db['pass']);
mysql_select_db($db['db']);
}
//---------------------------
// Perform MySQL Query now..
//---------------------------
function query ($sql)
{
static $i = 0;
if (!$sql)
{
echo $i;
return;
}
$i++;
return mysql_query ($sql);
}
//---------------------------
// MySQL Retrieval Functions
//---------------------------
function fetch_result ($sql)
{
if (empty($sql))
{
die ("No query supplemented : (Fetch Result)");
}
else
{
return mysql_result($sql,0);
}
}
function fetch_array ($sql)
{
if (empty($sql))
{
die ("No Query Supplemented : (Fetch Array)");
}
else
{
return mysql_fetch_array($sql);
}
}
}
//+------------------------------
// Initiate Everything MYSQL Now
//+------------------------------
$do = new mysql;
$do->init();
//+------------------------------
// Now Lets Begin Initialization
//+------------------------------
$thread = $_GET['t']; // Grab $_GET Variable
######################################################################
######################################################################
#include_once("./header.inc");
######################################################################
# If you want to use your own template uncomment the "Include_once"
# directive above, otherwise feel free for the script to use its
# own built in template. -- Trigunflame
######################################################################
######################################################################
if ($layout['status'] == 1)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?php echo $site['name']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 14px;
}
.style2
{
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
}
.style4
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
.style5
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-style: italic;
font-weight: bold;
font-size: 14px;
}
.style8
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
}
.style9
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style10
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 1px;
}
-->
</style>
</head>
<body>
<?php
}
if ($db['limit'] == 1)
{
$limit = "LIMIT 1";
}
else
{
$limit = NULL;
}
$topic = $do->fetch_array($do->query(" SELECT * FROM thread
WHERE threadid=\"".$thread."\"
LIMIT 1"));
$query = $do->query(" SELECT * FROM post
WHERE threadid=\"".$thread."\"
ORDER BY postid
ASC $limit");
?>
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#D2D2D2">
<tr>
<td colspan="3"><span class="style1"><?php echo $topic[title]; ?></span></td>
</tr>
<?php
$i = 1;
while ($show = $do->fetch_array($query))
{
?>
<tr>
<td width="20%" align="center" bgcolor="#E0E0E0"><span class="style4"><?php echo date("m.d.y", $show[dateline]);; ?></span></td>
<td width="40%" bgcolor="#E0E0E0" class="style8"><?php echo $show[title]; ?></td>
<td width="40%" align="right" bgcolor="#E0E0E0" class="style8">Post: <?php echo $i; ?> </td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#F0F0F0"><span class="style5"><?php echo $show[username].'</span><br /><span class="style4">User ID: '.$show[userid]; ?></span></td>
<td colspan="2" bgcolor="#F0F0F0"><table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<td valign="top"><span class="style9"><?php echo str_replace("\n","<br />",$show[pagetext]); ?></span></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" bgcolor="#F0F0F0"><span class="style4"> </span></td>
<td colspan="2" bgcolor="#F0F0F0"> <span class="style8">Button1 Button2 Button3 Button4 Button5</span></td>
</tr>
<tr>
<td width="20%" align="center" bgcolor="#D2D2D2" class="style10"> </td>
<td width="40%" bgcolor="#D2D2D2" class="style10"> </td>
<td width="40%" align="right" bgcolor="#D2D2D2" class="style10"> </td>
</tr>
<?php
$i++;
}
?>
<tr>
<td colspan="3"><span class="style2"><a href="#">Return to Top</a></span></td>
</tr>
</table>
<?php
######################################################################
######################################################################
#include_once("./footer.inc");
######################################################################
# If you want to use your own template uncomment the "Include_once"
# directive above, otherwise feel free for the script to use its
# own built in template. -- Trigunflame
######################################################################
######################################################################
if ($layout['status'] == 1)
{
?>
</body>
</html>
<?php
}
?>
|