diff options
-rw-r--r-- | index.php | 11 | ||||
-rw-r--r-- | setup.sql | 2 |
2 files changed, 10 insertions, 3 deletions
@@ -41,8 +41,13 @@ include_once 'header.php'; echo '<tr><td class="left">'; echo '<h4><a href="category.php?id=' . $row['cat_id'] . '">' . $row['cat_name'] . '</a></h4>'; echo $row['cat_description']; - echo '</td><td class="right">' . $thread['thread_subject'] . '<br>'; - echo '<small>by <b>' . $thread['user_name'] . '</b></small></td></tr>'; + if ($thread) { + echo '</td><td class="right">' . $thread['thread_subject'] . '<br>'; + echo '<small>by <b>' . $thread['user_name'] . '</b></small></td></tr>'; + } else { + $no_threads_msg = 'There are no threads in this category yet.'; + echo '</td><td class="right"><small>'. $no_threads_msg .'</small></td>'; + } } mysqli_stmt_close($stmt); @@ -75,4 +80,4 @@ include_once 'header.php'; </table> <?php include_once 'footer.php'; -?>
\ No newline at end of file +?> @@ -37,3 +37,5 @@ ALTER TABLE threads ADD FOREIGN KEY(thread_cat) REFERENCES categories(cat_id) ON 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; + +INSERT INTO categories (cat_name, cat_description) VALUES ("General", "Discussion of anything that doesn't fit in the other categories"); |