1

I've create a search.php and it is already connected on database. I want the result to be clickable. for example, when you search a name on facebook, the result is clickable and then when you click it, it will directly go to user's profile. what code will i add? Here is my code:

  $sql="SELECT schoId, schoSurname, schoFirstname FROM tblscholar WHERE schoSurname LIKE '%" . $name .  "%' OR schoFirstname LIKE '%" . $name ."%'";
  $result=mysql_query($sql) or die(mysql_error());
  while($row=mysql_fetch_array($result)){
  $schoSurname=$row['schoSurname'];
  $schoFirstname=$row['schoFirstname'];
  $schoId=$row['schoId'];
  echo $row["schoSurname"];
  echo $row["schoFirstname"];
  • with "clickable result" you mean something like a link? – Beat Jan 24 '14 at 13:23
  • Possible duplicate of [How do I redirect to another page in jQuery?](http://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-page-in-jquery) – cutiepatootie Jan 17 '17 at 03:46

1 Answers1

1

What you need to do really depends on how your user profile link looks like, but it should be something like this

echo '<a href="http://www.yourdomain.com/user/'.$schoId.'">'.$schoFirstname.' '.$schoSurname.'</a>';

which would output

Name Surname

Of course you don't need an absolute URL if you're within the same domain, but I hope it's easier to understand like this.

spiel
  • 347
  • 3
  • 15
  • thanks for your answer. so it means that every user must have their own .php? – cutiepatootie Jan 24 '14 at 13:40
  • @cutiepatootie Generally speaking you have one template user page which loads the user data based on the user id from the URL. So you don't have to create hundreds upon hundreds of user files, but you do need to know how to output all data correctly. – spiel Jan 24 '14 at 13:48
  • @cutiepatootie If this was the right answer please do not forget to mark is as such :) – spiel Jan 29 '14 at 11:18