Hi my Prof. wants me to create a forum website from scratch. This forum contains only basic functionalities like creating a forum,a new thread in the forum, post a reply.

So I created a database which contains these tables:
Users
Groups
Forums
Topics
Posts

now in my homepage I want to display a list of available forums
i know i have to fetch these list from my database my question is how can I display these list of forums like how this forum site works? I mean when the forums are displayed I can click on it and and displays the threads then when i click on a certain thread displays the posts that belongs to the thread.I already tried querying the contents of a table but I cant click on it.

Please tell me how to do it, an example code I hope or send me links for tutorials or ebooks... THANK YOU

Dani AI

Generated

A quick, practical approach: render each forum row as an HTML link that points to a topics page (passing the forum id or a slug). The topics page reads that id, queries topics WHERE forum_id = ?, and renders links to the posts page. This maps directly to the tables you already created — forums -> topics -> posts — and is what makes forum names "clickable" in real sites. 's tutorial is a useful walkthrough; the snippet below shows the simple rendering step that often gets missed.

<?php
// assume $pdo is a configured PDO instance
$stmt = $pdo->query("SELECT id, title, description FROM forums ORDER BY title");
while ($f = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $id = (int)$f['id'];
    $title = htmlspecialchars($f['title'], ENT_QUOTES, 'UTF-8');
    $desc  = htmlspecialchars($f['description'], ENT_QUOTES, 'UTF-8');
    echo "<div class=\"forum\">
            <a href=\"topics.php?forum_id={$id}\">{$title}</a>
            <p>{$desc}</p>
          </div>";
}
?>

On topics.php read forum_id as an integer, use a prepared statement, then loop and emit <a href="posts.php?topic_id=..."> for each topic (escape titles the same way). To show counts or last-post info on the forum list, use a LEFT JOIN with GROUP BY or maintain counters on the topics table for performance:

SELECT f.id, f.title, COUNT(t.id) AS topic_count, MAX(p.created_at) AS last_post_at
FROM forums f
LEFT JOIN topics t ON t.forum_id = f.id
LEFT JOIN posts p ON p.topic_id = t.id
GROUP BY f.id, f.title;

Security/troubleshooting notes: always cast ids to integers, use prepared statements for user input, and HTML-escape output to prevent XSS. If links render as plain text or are not clickable, view-source to confirm <a> tags are present (not escaped), and use browser devtools to check for overlays or CSS that blocks clicks (z-index, absolute positioned elements). For coursework keep it simple; for production add pagination, indexing on forum_id/topic_id, and consider slugged URLs for nicer links. already has the right schema — the missing step is rendering those rows as anchors and wiring the topics/posts pages to accept the id and query accordingly.

Heres i nice little tutorial i quickly found for you.

Should walk you right through the process

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.