Jump to content

[SOLVED] showing search results as a profile link?


clint

Recommended Posts

Hello all,

I am having a problem with a search page I was trying to create. Im sure it is something really simple I am not doing but being php handicapped as I am, it has got me a bit confused.

What I am trying to do is, by using three list boxes (country,state,industry) you can see user profiles. For example: you select your country, then your state and then industry and hit search. It then shows you a list of registered users based on those 3 list boxes, but as a link to member_profile.php so you can view the profile.

 

The code I have shows the list of users fine based on the list box criteria, but I am having problems making that data display as a link to the profile page.....maybe I am just going about it all wrong?

 

Here is the code that shows the list of users and seems to work fine, its just the link:

 

 <?php
include 'dbc.php';

//select which database you want to edit
mysql_select_db("users");
$search=$_POST["search"];

//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$result = mysql_query("SELECT * FROM users WHERE country LIKE '%$country%' AND state LIKE '%$state%' AND industry LIKE '%$industry%'");


//grab all the content
while($r=mysql_fetch_array($result))
{	
   //the format is $variable = $r["nameofmysqlcolumn"];
   //modify these to match your mysql table columns
  
   $full_name=$r["full_name"];
   
   
   //display the row
   echo "$full_name <br>";


  
  
?>

 

Could anybody put me on the right path for this one.

Thanks in advance for the help and  I do apologize in advance if this has been posted here before.....searched for it beforehand.

Just adding to the last reply. You'll also likely want to pass an id or some other identifier to the to the page your linking too also. Such as....

 

echo '<a href="somelinkhere.php?id=' . $r['userid'] . '">'.$r['full_name'].'</a><br />';

 

This way, on the somelinkhere.php page you can grab the id....

 

$id = GET['id']

 

And use that in a further query to get the users details and display them.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.