
May 12th, 2003, 05:15 PM
|
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 6
|
|
|
sorry
i knew I shouldve shown you the code... but there is so much oi. here:
PHP Code:
<?php
ob_start();
require_once('Connections/users.php'); ?>
<?php
mysql_select_db($database_users, $users);
$query_Recordset1 = "SELECT * FROM comments, log, news, online, `session`, users";
$Recordset1 = mysql_query($query_Recordset1, $users) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//include('class.security.php');
$dtlsSecurity = new Security;
$dtlsSecurity->ExtraFieldNames('firstname,lastname');
$dtlsSecurity->StoreSession_TableName('session');
$dtlsSecurity->Log_TableName('log');
$dtlsSecurity->FieldNames('sessionid', 'userid', 'username', 'auth');
$IsLoggedIn = $dtlsSecurity->IsLoggedIn();
$details = $dtlsSecurity->GetData();
if($IsLoggedIn)
{
?>
<?php
}
else
{
?>
<?php
}
echo '<a href="index.php">Home</a> | <a href="news.php">News</a><br>';
switch($_GET['what'])
{
case "comment";
ShowCommentForm();
break;
case "process";
ProcessComment();
break;
default;
ShowNews();
break;
}
function ProcessComment()
{
global $IsLoggedIn, $details;
if($IsLoggedIn != 1)
header("Location: login.php");
//show selected news post
mysql_query("INSERT INTO `comments` (`id`, `newsid`, `userid`, `comment`, `date`) VALUES (0, '{$_POST['newsid']}', '{$details[0]}', '{$_POST['comment']}', NOW())");
?>
Comment Posted<br><br>
<a href="news.php?nId=<?php echo $_POST['newsid']; ?>">Continue</a><br>
<body>
<html>
<?php
}
function ShowCommentForm()
{
global $IsLoggedIn, $details;
if($IsLoggedIn != 1)
header("Location: login.php");
//show selected news post
$result = mysql_query("SELECT * FROM news WHERE id = '{$_GET['nId']}'");
$row = mysql_fetch_array($result);
?>
<strong>Post comment for...</strong>
<br><br>
<?php echo $row['article']; ?>
<br><br><hr>
<form method="post" action="news.php?what=process">
<textarea name="comment" cols="50" rows="10"></textarea><br>
<input name="newsid" type="hidden" value="<?php echo $_GET['nId']; ?>">
<input type="submit" value="Post Comment">
</form>
<?php
}
function ShowNews()
{
if(isset($_GET['nId']) && is_numeric($_GET['nId']))
{
//show selected news post
$result = mysql_query("SELECT * FROM news WHERE id = '{$_GET['nId']}'");
$row = mysql_fetch_array($result);
echo "<hr>" . $row['article'];
echo "<br><br><strong>Comments</strong><hr>";
$cResult = mysql_query("SELECT * FROM comments WHERE newsid = '{$_GET['nId']}'");
if(mysql_num_rows($cResult) == 0)
{
echo "no comments for this news post";
}
while($row = mysql_fetch_array($cResult))
{
?>
Posted By:
<?php
$query = mysql_query("SELECT * FROM users WHERE userid = '{$row['userid']}'");
echo mysql_result($query, 0, 4) . ' ' . mysql_result($query, 0, 5);
?>
<br>
<?php
echo $row['comment'];
?>
<hr>
<?php
}
echo "<center><a href='news.php?what=comment&nId=" . $_GET['nId'] . "'>Add Comment</a></center>";
}
else
{
$result = mysql_query("SELECT * FROM news ORDER BY date DESC");
if(mysql_num_rows($result) == 0)
{
echo "<hr>no news posts to be displayed";
}
while($row = mysql_fetch_array($result))
{
?>
<hr>
<?php echo $row['article']; ?><br>
<div align="right">
<?php
if($IsLoggedIn == 1)
echo '<a href="news.php?what=addcomment">Add Comment</a> | ';
?>
<a href="news.php?nId=<?php echo $row['id']; ?>">Read Comments</a>
</div>
<?php
}
}
}
?>
its basically what Ben Rowe set up exactly, but it isn't showing anything but the links at the top for news and home.
any ideas?
|