Solved

php search results that have link on them

Posted on 2011-03-16
5
358 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 250 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 250 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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.

628 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