Jump to content

[SOLVED] Search Result with Link


PHPro

Recommended Posts

Links to what? Profile pages?

 

As an example.

 

<?php

$sql = "SELECT id, uname FROM users";
if ($result = mysql_query($sql)) {
  if (mysql_num_rows($result)) {
    while ($row = mysql_fetch_assoc($result)) {
      echo "<a href='prefile.php?id={$row['id']}'>{$row['uname']}</a>";
    }
  }
}

 

profile.php

<?php

if (isset($_GET['id'])) {
  $id = mysql_real_escape_string($_GET['id']);
  $sql = "SELECT email FROM users WHERE id = $id LIMIT 1";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      $row = mysql_fetch_assoc($result);
      echo $row['email'];
    }
  }
}

Link to profile

 

Thank you so much Thorpe.Thats exactly what I'm looking for. You refer to this as a pagination right?

thanks again sir!

 

Nope, nothing to do with pagination. Pagination is when you have so many results from one query that you split those results over several pages. Much how this board is split into pages, otherwise this page would need to display something like 150000 records at once.

  • 11 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.