maxihobbs Posted March 8, 2010 Share Posted March 8, 2010 Ive just set up a members table whereby the user clicks on the the member page and is shown each registered users details (name, email, about etc), like a memberlist page. I now want to able to allow each user to be able to view any profile by selecting view profile on any user they so wish? Ive no idea where to start, can anyone help here Any help would be fantastic! Thanks Link to comment https://forums.phpfreaks.com/topic/194543-php-view-profile-code/ Share on other sites More sharing options...
xnowandtheworldx Posted March 8, 2010 Share Posted March 8, 2010 Set up a query that grabs the users data from the database with the given id. example: $id = mysql_real_escape_string($_GET['user_id']); //Lets say it equals 1 $query = "SELECT * FROM users_table WHERE id = " . $id; $result = mysql_query($query); $data = mysql_fetch_array($result); echo $data['username']; //if the row is a username, it would echo that username I tried to explain as best as possible, I'm not good at explaining. Hope I was at least able to help a little. EDIT: I think I may have misunderstood what you meant. If I did, I apologize. Link to comment https://forums.phpfreaks.com/topic/194543-php-view-profile-code/#findComment-1023178 Share on other sites More sharing options...
Anti-Moronic Posted March 8, 2010 Share Posted March 8, 2010 Ive just set up a members table whereby the user clicks on the the member page and is shown each registered users details (name, email, about etc), like a memberlist page. I now want to able to allow each user to be able to view any profile by selecting view profile on any user they so wish? Ive no idea where to start, can anyone help here Any help would be fantastic! Thanks xnowandtheworldx has got 90% of what you want - which is retrieving the actual data. Now you just need a link so you know what data to receive. With xnowandtheworldx code you can now view a page liek this and it will retrieve the data: http://domain.com/?user_id=useridnum But approaching that is down to you. You will likely need to separate this so the user link is: /profile/user_id=useridnum or the nicer htaccess way: /profile/useridnum/ also, make damn sure to validate whatever variable you use within your sql query. If user_id is a num, use: $id = intval($_GET['user_id']); ..eek, probably just did more to confuse you. Read xnowandtheworldx code over and over until you get the gist of how to retrieve specific profiles. Then work on the link your website will use to run the query. Link to comment https://forums.phpfreaks.com/topic/194543-php-view-profile-code/#findComment-1023182 Share on other sites More sharing options...
maxihobbs Posted March 8, 2010 Author Share Posted March 8, 2010 Thanks for the feedback. Where would this code be input then, I've read it over and over and see how it works but am confused as to where to implement it. Here's my page so far: <div class="dividerA"> <?php $username=""; $password=""; $database=""; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM users"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th>Member Number</font></th> <th>First Name</font></th> <th>Last Name</font></th> <th>Email</font></th> <th>About</font></th> <th>Profile</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"id"); $f2=mysql_result($result,$i,"first"); $f3=mysql_result($result,$i,"last"); $f4=mysql_result($result,$i,"email"); $f5=mysql_result($result,$i,"about"); ?> <tr> <td><?php echo $f1; ?></font></td> <td><?php echo $f2; ?></font></td> <td><?php echo $f3; ?></font></td> <td><?php echo $f4; ?></font></td> <td><?php echo $f5; ?></font></td> <td><?php echo 'View Profile'; ?></font></td> </tr> <?php $i++; } ?> </div> Link to comment https://forums.phpfreaks.com/topic/194543-php-view-profile-code/#findComment-1023203 Share on other sites More sharing options...
trq Posted March 8, 2010 Share Posted March 8, 2010 This thread should get you started. Link to comment https://forums.phpfreaks.com/topic/194543-php-view-profile-code/#findComment-1023229 Share on other sites More sharing options...
maxihobbs Posted March 8, 2010 Author Share Posted March 8, 2010 Thanks a lot for the thread pointer mate, Ill have a crack tomorrow Link to comment https://forums.phpfreaks.com/topic/194543-php-view-profile-code/#findComment-1023265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.