Category |
- Latest Topic |
+ Latest Thread |
';
echo '';
echo $row['cat_description'];
- echo ' | Example topic right here 1 hour ago by cflip | ';
+ echo '
Example thread 1 hour ago by example user | ';
}
mysqli_free_result($result);
diff --git a/setup.sql b/setup.sql
index 642c46a..f51250b 100644
--- a/setup.sql
+++ b/setup.sql
@@ -15,25 +15,25 @@ CREATE TABLE categories (
PRIMARY KEY (cat_id)
) ENGINE = InnoDB;
-CREATE TABLE topics (
- topic_id INT(8) NOT NULL AUTO_INCREMENT,
- topic_subject VARCHAR(255) NOT NULL,
- topic_date DATETIME NOT NULL,
- topic_cat INT(8) NOT NULL,
- topic_author INT(8) NOT NULL,
- PRIMARY KEY (topic_id)
+CREATE TABLE threads (
+ thread_id INT(8) NOT NULL AUTO_INCREMENT,
+ thread_subject VARCHAR(255) NOT NULL,
+ thread_date DATETIME NOT NULL,
+ thread_cat INT(8) NOT NULL,
+ thread_author INT(8) NOT NULL,
+ PRIMARY KEY (thread_id)
) ENGINE = InnoDB;
CREATE TABLE posts (
post_id INT(8) NOT NULL AUTO_INCREMENT,
post_content TEXT NOT NULL,
post_date DATETIME NOT NULL,
- post_topic INT(8) NOT NULL,
+ post_thread INT(8) NOT NULL,
post_author INT(8) NOT NULL,
PRIMARY KEY (post_id)
) ENGINE = InnoDB;
-ALTER TABLE topics ADD FOREIGN KEY(topic_cat) REFERENCES categories(cat_id) ON DELETE CASCADE ON UPDATE CASCADE;
-ALTER TABLE topics ADD FOREIGN KEY(topic_author) REFERENCES users(user_id) ON DELETE RESTRICT ON UPDATE CASCADE;
-ALTER TABLE posts ADD FOREIGN KEY(post_topic) REFERENCES topics(topic_id) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE threads ADD FOREIGN KEY(thread_cat) REFERENCES categories(cat_id) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE threads ADD FOREIGN KEY(thread_author) REFERENCES users(user_id) ON DELETE RESTRICT ON UPDATE CASCADE;
+ALTER TABLE posts ADD FOREIGN KEY(post_thread) REFERENCES threads(thread_id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE posts ADD FOREIGN KEY(post_author) REFERENCES users(user_id) ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/thread.php b/thread.php
new file mode 100644
index 0000000..52ad8b3
--- /dev/null
+++ b/thread.php
@@ -0,0 +1,67 @@
+
+
+
' . $row['thread_subject'] . '
';
+ echo 'Created by
' . $row['user_name'] . ' on ' . date('M d, Y', strtotime($row['thread_date'])) . '';
+ $thread_id = $row['thread_id'];
+ }
+}
+
+echo '';
+
+mysqli_free_result($result);
+
+$sql = "SELECT post_content, post_date, post_author, user_id, user_name FROM posts LEFT JOIN users ON post_author = user_id WHERE post_thread = " . mysqli_real_escape_string($dbc, $_GET['id']);
+$result = mysqli_query($dbc, $sql);
+
+if (!$result) {
+ die('Error trying to display posts: ' . mysqli_error($dbc));
+}
+
+if (mysqli_num_rows($result) == 0) {
+ echo '
';
+} else {
+ echo '
';
+ while ($row = mysqli_fetch_assoc($result)) {
+ echo 'Posted by ' . $row['user_name'] . ' ' . date('m/d/Y g:ia', strtotime($row['post_date'])) . ' | ';
+ echo '' . $row['post_content'] . ' |
';
+ }
+ echo '
';
+}
+
+mysqli_free_result($result);
+
+if (isset($_SESSION['signed_in'])) {
+ echo '
+
+ ';
+} else {
+ echo '
+
+ Sign in to reply to this thread
+
+ ';
+}
+
+include_once 'footer.php';
+?>
\ No newline at end of file
diff --git a/topic.php b/topic.php
deleted file mode 100644
index 751370b..0000000
--- a/topic.php
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
' . $row['topic_subject'] . '
';
- echo 'Created by
' . $row['user_name'] . ' on ' . date('M d, Y', strtotime($row['topic_date'])) . '';
- $topic_id = $row['topic_id'];
- }
-}
-
-echo '';
-
-mysqli_free_result($result);
-
-$sql = "SELECT post_content, post_date, post_author, user_id, user_name FROM posts LEFT JOIN users ON post_author = user_id WHERE post_topic = " . mysqli_real_escape_string($dbc, $_GET['id']);
-$result = mysqli_query($dbc, $sql);
-
-if (!$result) {
- die('Error trying to display posts: ' . mysqli_error($dbc));
-}
-
-if (mysqli_num_rows($result) == 0) {
- echo '
';
-} else {
- echo '
';
- while ($row = mysqli_fetch_assoc($result)) {
- echo 'Posted by ' . $row['user_name'] . ' ' . date('m/d/Y g:ia', strtotime($row['post_date'])) . ' | ';
- echo '' . $row['post_content'] . ' |
';
- }
- echo '
';
-}
-
-mysqli_free_result($result);
-
-if (isset($_SESSION['signed_in'])) {
- echo '
-
- ';
-} else {
- echo '
-
- Sign in to reply to this thread
-
- ';
-}
-
-include_once 'footer.php';
-?>
\ No newline at end of file
--
cgit v1.2.3