I am not strong in php , please help me with this question.

There is a task: to make a website with search by database.

I implemented the search, everything works, but it is necessary that by clicking on one of the search results, I was knocked out on a template page, in which all information from the given row would be displayed, ie the title, description, image ... Output everything in a loop I understand how, but how to make the infa of that link from the search I clicked on?

  • Thank you all, you helped me a lot, now everything works)) - vovaxxx

3 answers 3

The question is rather abstract ...

  1. You did a search.
  2. Find a lot of some elements, everyone has an Id.
  3. When combing all elements, you create a link to view this element, for example:

    echo '<a href="/show.php?id="' . $row['id'] . '...</a>'; 
  4. When you click on the link, you get into the php script file you created (here show.php)

  5. In this file, you get one row (row) knowing Id ( $_GET['id'] ) and everything is there and output:

     echo $row['id'] . ' ' . $row['name'] . .....; 

    Very vague question.

    This can be done in many ways. For example:

    1. The search result is a link of the form {ваш сайт}/?res={ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ строки поиска}
    2. After clicking on such a link, the request goes to your script, where you first well filter the request from any injections , and then take {ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ строки поиска} and, on the basis of it, return the template with the relevant information

      you need to figure out what get, post requests are. Then you will understand everything. The link to the record should be from the id of this record from the database, then when you go to the page you take id (from the address bar, this is a get request) and look for the necessary information in the database. The fastest and best option.