I am new to PHP. I have 10 links on the main page. I want to make a universal page that would appear after clicking on any of these links (links are homogeneous). Those. I don't want to write my html file for everyone. I want one template page and it would only replace the content (content is from a specific row in the base table) depending on which link was clicked.

How do you say it so that you can take your id on a certain line and output the line with this id from the table?

I would be very grateful for any help !!!))) At least in which direction to move.

    2 answers 2

    In haste like this:

    Links

    <a href="index.php?page=1">Ссылка 1</a> <a href="index.php?page=2">Ссылка 2</a> <a href="index.php?page=3">Ссылка 3</a> <a href="index.php?page=4">Ссылка 4</a> 

    At the top of index.php

     $page = isset($_GET['page']) ? intval($_GET['page']) : 1; //1-ссылка по-умолчанию 

    Below is a query to the database

     $result = mysql_query("SELECT * FROM `table` WHERE `id`=$page"); $data = mysql_fetch_assoc($result); 

    Conclusion on the page

     echo "<h2>".$data['title']."</h2> <div>".$data['text']."</div>"; 
    • Thank you very much DemoS !!!!!! I will try!!! I've been here for the first time and rewarded you with the wrong number))) I pressed it in the wrong place))) - qwerty17
    • Yes, not at all, try. Just in case, to the left of the answer there is a check mark to accept the answer. If it suits you, accept it, otherwise it will hang in your un-accepted. And people who have many such unaddressed questions are answered reluctantly. - DemoS
    • Demos, you helped me a lot) now I started reading about the reputation on the site and saw that I spoiled it for you (sorry please ... for some reason I put 0 instead of 10 for you ... the browser is buggy for some reason ... sorry and thanks again for the answer! what would the newbies do without people like you) - qwerty17
    • It's okay! I am glad to help! )) - DemoS

    GET request will help you. For each link you need to add ?id=%идентификатор% A to get it on the target page can be from the variable $_GET['id']