我刚刚进入了一些复杂的数据库(对我来说很复杂),我一直在想我是否会这样做。以下是我想要实现的。为特定用户存储帖子和数据,然后检索数据
目标:存储注册用户的发布数据。然后检索该用户的发布数据。
我有注册用户的表称为members
,它包含了userid
,username
,timeReg
,password
。我如何为每个用户存储更多数据?特别是他们的posts
。
如果用户登录,我该如何显示他们的帖子,而不是其他人的帖子?我是否创建了一个名为posts
的新表来存储数据?或者我在members
表内添加posts
字段?
到目前为止,我在完全没有用户,但用于检索的一切代码如下:
$sql_query = "SELECT * FROM members ORDER BY timeReg DESC";
$result = mysql_query($sql_query);
if (mysql_num_rows($result)) {
echo "<table border='1' cellspacing='0' width='62%'>";
echo "<tr>";
echo "<th width='15%'>Time Registered</th>";
echo "<th width='15%'>Username</th>";
echo "<th width='15%'>Encrypted Password</th>";
echo "<th width='15%'>IP Address</th>";
echo "<th width='2%'>Delete User</th>";
echo "</tr>";
while ($row = mysql_fetch_row($result))
{
echo "<tr>";
echo ("<p><td>" .genericTime($row[2]). "</td><td>$row[0]</td><td>$row[1]</td><td><i>$row[3]</i></td><td><a href=\"delete.php?time=$row[2]&user=$row[0]&pass=$row[1]\"><center>[x]</center></a></td></p>");
echo "</tr>";
}
echo "</table>";
}
else
{
echo "*No Members*";
}
我会使用join方法将字段连接在一起吗?谢谢回复。 – Kyle 2011-03-08 10:05:42