Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

php search results that have link on them

Posted on 2011-03-16
5
Medium Priority
?
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
The viewer will learn how to dynamically set the form action using jQuery.
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…

715 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