Accurax Posted December 11, 2006 Share Posted December 11, 2006 Ive been reading around and i cant seem to find anything that mentions how to actually do this, so if someone could point me in the direction of some referance material id be very gratefull. This is where I am, and what im looking for ;I have created a membership system, in which members can login, and create a profile for themselves, with photo's etc, howwever, a profile is not much use unless other people can view it.Basically, im trying to find out how i can go about listing all the profiles on my sirte, and allowing other users to browse through them.Like i said, i cant seem to find a referance on doing this, so any links and or pointers are much appreciated.Thanks guys Quote Link to comment Share on other sites More sharing options...
marcus Posted December 11, 2006 Share Posted December 11, 2006 You can do this easily with some mysql queries.[code]<?php$id = $_GET['id'];if(isset($id)){ $sql = "SELECT * FROM `users` WHERE id =$id"; $res = mysql_query($sql) or die(mysql_error()); $num = mysql_numrows($res); $row = mysql_fetch_assoc($res); if($num > 0){ echo "Welcome to $row['username']'s profile!<br><br>\n"; echo "Name: $row['name']<br>\n"; echo "Email: $row['email']<br>\n"; echo "Picture: <img src='".$row['image']."'><br>\n"; //and whatever is in your database }else { echo "That user does not exist!\n"; }}else {echo "You have no user id specified!";}?>[/code] Quote Link to comment Share on other sites More sharing options...
marcus Posted December 11, 2006 Share Posted December 11, 2006 And for showing a members list you can do:[code]<?php$sql = "SELECT * FROM `users`";$res = mysql_query($sql) or die(mysql_error());$num = mysql_numrows($res);if($num == 0){echo "no users";}else {while($row = mysql_fetch_assoc($res)){echo "<a href=profile.php?id=$row['id']>$row['username']</a>\n";}mysql_free_result($res);}?>[/code] Quote Link to comment Share on other sites More sharing options...
Accurax Posted December 11, 2006 Author Share Posted December 11, 2006 Thats what i started thinking . allthough i wasnt sure how to acheive it, my idea is to display all of the pictures of the members and let the user select which profile to see from the thumbnails ... I cant get my head around how to pass the variables so that my script knows which profile they selected.Then i started thinking that i needed to dynamically create pages for each user....... as this would allow them to give the link to their friends so they could go straight to their profile.... which is an idea that i like.this will eventually be a list generated by some search queries performed by the user, so the thumbnails will be dynamically created aswell.I think once i figure out the basics of identifying which profile was selected ill be half way there tbh Quote Link to comment Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 Any chance someone knows where i can find out how this works........ I dont want to simply copy and paste code, allthoguh i appreciate examples that are given..... i really need to understand this...... How does a php script know which profile it is meant to display? Quote Link to comment Share on other sites More sharing options...
TEENFRONT Posted December 12, 2006 Share Posted December 12, 2006 okurl is http://yoursite.com/show-users.php?userid=55 - so someone visits this link..you can use GET to grab the userid var from the above url$userid = $_GET['userid'];the the sql statement then selects the info from the userid$sql = "SELECT * FROM `users` WHERE id =$userid"; see the WHERE id =$userid"; part?sorted, this is how it lists info from that specific user. taking into account that your table has a unique id for each user, else it will bugger up if 2 people have the same id etc. Quote Link to comment Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 Yeah i get that, but ive only use POST and FILES so far lol .... and i was completely flumoxed how i pass the id of the profile that the user wants to look at without using some sort of form Quote Link to comment Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 Is any able to explain this to me a little...... i just need a kick to get started.... google doent return much, and im stumped.... please :( Quote Link to comment Share on other sites More sharing options...
liam1412 Posted December 12, 2006 Share Posted December 12, 2006 Okay here goes!Table ExampleTable name - userstable fields - user_id, username, thumbnail_link blah, blah, blah.$sql_user_query = "SELECT * FROM users";$sql_user_result = mysql_query($sql_user_query);Then you start to images out the profiles using a while loop and details using a while loop.<?phpwhille($user_array= mysql_fetch_array($sql_user_result)){?><tr><td>[color=green](a href="view_profile.php?userid[/color]<?php echo $user_array['user_id'];?>[color=green]")<img src="images/[/color]<?php echo $user_array['thumbnail_link'];?>[color=green]" width="100" height="100">(/a)[/color]</td></tr>I have had to change the link tag to avoid the BB parser in this software so (a) (/a) should obviousl be the usual html link tagsHere the php is echoing at the row for each array it finds in the database - The <a href="view_profile.php?=***dynamically sets the URL to be "view_profile.php?=(whatever the userid is in the array)Now when they click the image it will link to view_profile.php and the query string will be after. (view_profile.php?userid=1) for examplenow collect the variable in the code for view_profile.php using the following$userid = $_GET['userid'] This collects the userid from the query string in the URL.Hope that helps. Tried to explain best I can. Quote Link to comment Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 That helps more than you can imagine mate thankyou so much :) Quote Link to comment Share on other sites More sharing options...
liam1412 Posted December 12, 2006 Share Posted December 12, 2006 No problem at all.Im pretty new to this but once told this I managed to simplify so many of my scripts using the same principal. Cheers Quote Link to comment Share on other sites More sharing options...
Accurax Posted December 12, 2006 Author Share Posted December 12, 2006 Im having a few issues with it.... its in another thread in this forum.... dont suppose u could take a look could you? 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.