Lucky2710 Posted July 21, 2010 Share Posted July 21, 2010 I wanna incorporate into my site where members can view each others profiles. I've got a page a members pages that lists all members. <?php include 'dbc.php'; page_protect(); //---------------------------------------- //mySQL Connection Start mysql_connect ("localhost","username","password"); mysql_select_db ("sports"); //mySQL Connection End function printMembersList(){ //Get User id #'s $sql="SELECT user_name FROM users WHERE user_profile=1"; $result=mysql_query($sql); while($row = mysql_fetch_object($result)) { $ids[] = $row->user_name; } //Done Getting User id #'s for($i=0; $i< count($ids); $i++) { echo ' <tr> <td>'.$ids[$i].'</td> </tr> '; if ( (($i+1) % 6) == 0 ) echo $newrow="</tr><tr>"; // change 6 to 8 and see } } ?> I can call the function printMembersList and it print a table row with the members user names. What i want someone to explain to me is how to put a link on each name to send them to view their profile. I've got the page i want it to go to created but i don't have a clues on how to put them together. below is the code for the page i want it to got to. <?php include 'dbc.php'; page_protect(); //---------------------------------------- //mySQL Connection mysql_connect ("localhost","username","password"); mysql_select_db ("sports"); //-------------------------------------------------------------------------------------- $member_clicked = ; //THE SELECTED USER ON PREVIOUS PAGE (Member List Page). $rs_settings = mysql_query("select * from users where id='$member_clicked'"); //-------------------------------------------------------------------------------------- ?> If someone could point me in the right direction on how to do this i would appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/208417-question/ Share on other sites More sharing options...
CagedApe Posted July 21, 2010 Share Posted July 21, 2010 Are you simply asking how to put a link in your result? If so this is how you'd do it. Change echo ' <tr> <td>'.$ids[$i].'</td> to echo ' <tr> <td>'."<a href='profilepage.php'>$ids[$i]".'</a></td> Quote Link to comment https://forums.phpfreaks.com/topic/208417-question/#findComment-1089117 Share on other sites More sharing options...
Lucky2710 Posted July 21, 2010 Author Share Posted July 21, 2010 i'm asking that an then on the other page how will the linked to page know which link was clicked? what do i need to put in the second page right here... $member_clicked = ;//The Selected User on Previous (Member List Page). !!!!!!!HERE!!!!!!!<----- $rs_settings = mysql_query("select * from users where id='$member_clicked'"); ?> Thats what i don't have a clue on. Quote Link to comment https://forums.phpfreaks.com/topic/208417-question/#findComment-1089123 Share on other sites More sharing options...
CagedApe Posted July 21, 2010 Share Posted July 21, 2010 You'd do this: echo ' <tr> <td>'."<a href='profilepage.php?id=$ids'>$ids[$i]".'</a></td> Then your profilepage will use $_GET to find their username like this: if (isset($_GET['id']) && $_GET['id']!='') { $UserId=$_GET['id']; } Quote Link to comment https://forums.phpfreaks.com/topic/208417-question/#findComment-1089130 Share on other sites More sharing options...
Lucky2710 Posted July 21, 2010 Author Share Posted July 21, 2010 Closer but still no cigar! Now from the members page when you click on a name yes in the address bar it goes to (http://sports.nodinelandscaping.com/phplogin_v2.3/members_profile.php?id=Lucky2710) Lucky2710 is the user clicked that parts fine, but once its there the 2nd page aint pulling the user (ie. Lucky2710) to display the profile specific stuff on the page. So???!!! I'm still stuck! Dangit!!! Quote Link to comment https://forums.phpfreaks.com/topic/208417-question/#findComment-1089238 Share on other sites More sharing options...
Lucky2710 Posted July 21, 2010 Author Share Posted July 21, 2010 I'm just stupid that did work! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/208417-question/#findComment-1089264 Share on other sites More sharing options...
dezkit Posted July 21, 2010 Share Posted July 21, 2010 $UserId=mysql_real_escape_string($_GET['id']); don't forget. Quote Link to comment https://forums.phpfreaks.com/topic/208417-question/#findComment-1089279 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.