Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

php search results that have link on them

Posted on 2011-03-16
5
Medium Priority
?
365 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 1000 total points
ID: 35151197
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
ID: 35151328
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
ID: 35151359
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 1000 total points
ID: 35151362
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
ID: 35151461
yes thank you :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

972 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