clint Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 Are you willing to share more of the code with us, that seems very partial compared to what you are doing Quote Link to comment Share on other sites More sharing options...
Bricktop Posted September 22, 2009 Share Posted September 22, 2009 Hi clint, Change your echo code to read: //display the row echo '<a href="somelinkhere.php">'.$full_name.'</a><br />'; Hope this helps! Quote Link to comment Share on other sites More sharing options...
trq Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
clint Posted September 22, 2009 Author Share Posted September 22, 2009 Thanks so much for the replies. Exactly what I was looking for! I appreciate it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.