Search code examples
phphtmlformsforum

PHP create new page for each id


I'm trying to create a forum in php.

I allow users to create topics, then when I click into a topic I want to open a new page, where we will discuss the subject. How do I create that new page for each idTopic?

I'm trying to do this on topics page (page2 is the new page):

<a href='page2.php?id=".$row['idMessage']."'></a>

But how do I do it? I need to create unlimited pages, but on each one there are things for each idTopic.

I have more code, but do I need GET's?

EDIT: It worked!! Thank you Jefferson Salvador.


Solution

  • You create a default page that receives the topic for:

    $_GET['idTopic'];
    

    Then, you search the contents of that topic in the database. The page is the same, what changes is the content that comes from the bank, understood?

    topics.php

    <a href="forum.php?idTopic=<?= $row['idTopic']; ?> > <?= $row['topicName']; ?></a>
    

    forum.php

    $sql = 'SELECT* FROM messages where idTopic = '.$_GET['topic'];