Solved

php search results that have link on them

Posted on 2011-03-16
5
314 Views
Last Modified: 2012-05-11
hey people.

i have a search box that posts to my search.php page and i have it displaying UserName and userID and UserEmail according to the search term
 i am trying to add a link to go to that users profile. am not sure how to add this?
 here is a screen shot what it look like:
thank you





$query="SELECT * FROM members WHERE UserName OR UserEmail LIKE '%".$Search."%'"; 
	$result=mysql_query($query) or die ("bad query '$query' : ".mysql_error());
	if (mysql_num_rows($result)>0) {
		  while ($res=mysql_fetch_array($result)) {
		  	echo $res['UserEmail'].'<br>';	
		  	echo $res['UserName'].'<br>';	
			echo $res['MemberID'].'<br>';
		  }
	}else{
		echo 'No results';
	}

Open in new window

search.png
0
Comment
Question by:helpchrisplz
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 250 total points
Comment Utility
Do you mean it like this?

echo '<a href="profile.php?id=' . $res['MemberID']. '">' . $res['UserName'] . '</a><br>';

Open in new window

0
 
LVL 1

Author Comment

by:helpchrisplz
Comment Utility
ok so yes that will work now do i have the member id still? i see it in the browser address box. i need it in a variable to pull the searched users content in. can u explain that bit? sorry i am learning
0
 
LVL 8

Expert Comment

by:Rik-Legger
Comment Utility
You can retreive that with $_GET['id'],
but these are really the basics. Perhaps you should read some PHP tutorials first.
0
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 250 total points
Comment Utility
If you have that in your addressbar just get it with
<?php
 $userid = $_GET[id];
 echo"$userid";
 // for further data use query
 $query = "SELECT * FROM members WHERE Memberid = $userid";
 $result = mysql_query($query);
 $row = mysql_fetch_array($result);
 echo"$row[UserName]";
?>
0
 
LVL 1

Author Comment

by:helpchrisplz
Comment Utility
yes thank you :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now