我剛剛進入了一些複雜的數據庫(對我來說很複雜),我一直在想我是否會這樣做。以下是我想要實現的。爲特定用戶存儲帖子和數據,然後檢索數據
目標:存儲註冊用戶的發佈數據。然後檢索該用戶的發佈數據。
我有註冊用戶的表稱爲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