Here you can only search, but when you click on the user, click on the link, but there is nothing there, more precisely, it goes to its page (profile). How to make it so that you can browse on the one you click?

<head> <meta http-equiv="Counter-type" content="text/html; charset=utf=8" /> <title>поиск</title> </head> <body> <h2>поиск</h2> <form action='' method='get'> <input type='text' name='k' size='50' value='<?php echo $_GET[' k ']; ?>' /> <input type='submit' value='поиск'> </form> <hr /> <?php include 'core/init.php'; $k = $_GET['k']; $terms = explode(" ", $k); $query = "SELECT * FROM `users` WHERE "; foreach ($terms as $each) { $i++; if ($i == 1) $query .= "first_name LIKE '%$each%' "; else $query .= "OR last_name LIKE '%$each%'"; } mysql_connect("localhost", "root", ""); mysql_select_db("lr"); $query = mysql_query($query); $numrows = mysql_num_rows($query); if ($numrows > 0) { while ($row = mysql_fetch_assoc($query)) { $id = $row['user_id']; $title = $row['first_name']; $description = $row['last_name']; $avatar = $row['profile']; echo "<h2><a href='user?id=$id'>$title</a></h2> $description<br /><img src=$avatar width=150 height = 120><br />"; } } else echo "не найдено \"<b>$k</b>\""; mysql_close(); ?> </body> 

    1 answer 1

    First, we bring the link to an absolute view:

     echo "<h2><a href='/user/?id=$id'>$title</a></h2> $description<br /><img src=$avatar width=150 height = 120><br />"; 

    Next, in the file /user/index.php search for a user with the id obtained from $_GET['id'] and output it.

    • So writes Object not found! When you click on the user user, is this a folder? created user directory saved index.php there just need to write more specifically there? - LLIAKAJI
    • it all depends on the structure of your site, either a folder or a CNC. - FLK
    • Let there be a folder, there is an index.php that you need to write to it in order to get $ _GET ['user_id'] from there - LLIAKAJI
    • according to your style: $ id = $ _ GET ['id']; $ query = "select * from users where id =". $ id; and so on, I think you can configure security yourself, and processing the request and the output too. - FLK
    • that further is a continuation of the first or already in index.php to write, even if there were no errors not Object not found! - LLIAKAJI