Profile Based Website help

Thread Solved

Join Date: Oct 2009
Posts: 18
Reputation: enzo420 is an unknown quantity at this point 
Solved Threads: 0
enzo420 enzo420 is offline Offline
Newbie Poster

Profile Based Website help

 
0
  #1
Oct 19th, 2009
Hi all, so I'm looking to make a social network style site, just to help me understand php so please don't say anything about reinventing the wheel.

I'm looking for a way that when a user clicks on a name in the member list that it sends them to profile.php?id= so that profile.php can use it to identify whose profile they are looking for and can load the data for the profile from a mysql table.

member list
  1. <?php
  2. mysql_connect("localhost", "root", "") or die (mysql_error());
  3. mysql_select_db ("phplogin");
  4. $result = mysql_query ("SELECT * FROM users WHERE username=enzo");
  5. @$row = mysql_fetch_array($result);
  6. $id = $row['id'];
  7. echo '<a href="profile.php?id="$id">Enzo's Profile</a>';
  8. ?>
  9.  

profile
  1. $currentprofile = $_GET ['id'];
  2. mysql_connect("localhost", "root", "") or die (mysql_error());
  3. mysql_select_db ("phplogin");
  4. $result = mysql_query ("SELECT * FROM users WHERE id=$currentprofile");
  5. @$row = mysql_fetch_array($result);
  6. echo $row['profileinfo'];

is it wise to keep the profile info and "about me" user input text in a mysql table?

someone needs to write a decent tutorial on profiles that are user editable, people want to try recreate facebook/myspace to see how it works, its not about reinventing anything.

thanks, enzo
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 18
Reputation: enzo420 is an unknown quantity at this point 
Solved Threads: 0
enzo420 enzo420 is offline Offline
Newbie Poster
 
0
  #2
Oct 19th, 2009
  1. echo '<a href="profile.php?id="$id">Enzo's Profile</a>';
  2. ?>
  3.  

ive spotted the " after the = sign, wasnt supposed to be there but $id doesnt seem to contain anything?
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,405
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey
 
0
  #3
Oct 19th, 2009
Originally Posted by enzo420 View Post
  1. echo '<a href="profile.php?id="$id">Enzo's Profile</a>';
  2. ?>
  3.  

ive spotted the " after the = sign, wasnt supposed to be there but $id doesnt seem to contain anything?
If you're trying to get the value of $id in that string then you have to concatenate because you're using single quotes.
  1. echo '<a href="profile.php?id=' . $id . '">Enzo's Profile</a>';
  2.  
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 18
Reputation: enzo420 is an unknown quantity at this point 
Solved Threads: 0
enzo420 enzo420 is offline Offline
Newbie Poster
 
0
  #4
Oct 19th, 2009
thanks for your reply shawn, i got it sorted,

  1. <div id="apDiv12">
  2. <?php
  3. $connect = mysql_connect("localhost", "root", "") or die (mysql_error());
  4. $connect;
  5. mysql_select_db ("phplogin");
  6. $result = mysql_query ("SELECT * FROM users WHERE username='jackflash'");
  7. $row = mysql_fetch_array($result);
  8. $id = $row['id'];
  9. echo ('<a href=profile.php?id='.$id.'>Jack Flash</a>');
  10. ?>
  11. </div>
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,405
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey
 
0
  #5
Oct 19th, 2009
Originally Posted by enzo420 View Post
someone needs to write a decent tutorial on profiles that are user editable, people want to try recreate facebook/myspace to see how it works, its not about reinventing anything.

thanks, enzo
As for this, if you're just using it as a learning experience then it should be just that. It's not a very good learning experience if you just follow someone else's tutorial. The point of recreating something is to learn from the reverse engineering of it.

"Hmm, they have user profiles what is a user profile though. Let's see, a user has a name, and a phone number and an email address. But, oh, look a user has an ID too, that's probably the unique key."

"User's have friends but how do they do that? Ahh, I see, it's really just a list of user ids that they are friends with. But... I know that just storing a list of IDs breaks normalization so they probably have a many-to-many relationship of users. That makes more sense..."

Stuff like that.


(As an aside, echo doesn't need () it's not a function it's a language construct)
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC