<?php
session_start() ;
require_once 'echoHTML.php';
$linkCSS = NULL ;
$headTitle = ' 帖子列表 ' ;
$headMeta = NULL ;
$absPath = NULL ;
HTMLHead($linkCSS, $headTitle, $headMeta, $absPath ) ;
if ( !isset($_SESSION['user_id']) ) {
echo ' Please <a href="login.php">login</a> first ' ;
HTMLTail();
exit;
}
require_once 'connectDB.php' ;
connectDB() ;
$query = " SELECT * FROM users NATURAL JOIN posts NATURAL JOIN categories ORDER BY posted DESC ";
$result = mysql_query($query) or die(mysql_error());
echo "<table border='1'>" ;
echo "
<tr>
<th>Category</th>
<th>Title</th>
<th>Username</th>
<th>Posted</th>
</tr>
";
while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
$category = $row["category"] ;
$title = $row ["title"] ;
$username = $row["username"] ;
$posted = $row["posted"] ;
$post_id = $row["post_id"] ;
echo "<tr>";
echo "<td>$category</td>";
echo "<td>$title</td>";
echo "<td>$username</td>";
echo "<td>$posted</td>";
echo '<td><a href="viewPost.php?post_id='.$post_id.'">View</a></td>';
echo '<td><a href="removePost.php?post_id='.$post_id.'">Remove</a></td>';
echo '<td><a href="editPost.php?post_id='.$post_id.'">Edit</a></td>' ;
echo "</tr>";
}
echo "</table>" ;
echo ' <p> <a href="post.php">Add post</a> </p> ' ;
HTMLTail();
?>
-