Hi, I want to display the 'name' field from mysql database 'user' on my webpage once the user logs in.
There could be 2 people with the same login details but with different names so I would like it to display both names in 2 columns if possible.
so far I have:
$sql = "SELECT name users WHERE username = '" . $_SESSION['username'] . "'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "Hello, " . $row['name'] . ").";
"There could be 2 people with the same login details but with different names"
Do you mean there could be two people with the same username or two people with different usernames but the same "name" (name being display name, real name or whatever).???
thanks for your reply. Yes there could be 2 people with the same login details (username and password) but they have different names.
Coming to think of it. It would be easier if I put the same login details but with name1, name2 in the mysql database fields wouldnt it?
If so, back to my orginal question, how can I display these names on my webpage from the mysql. (name1, name2) already entered into mysql just a matter of retrieving them.
I'm not sure how to answer this, sorry if it sounds rude but...
Why on earth are you allowing 2 people to have the same username?
Your usernames should be unique, so if someone attempts to register with a username that is already in use it will say no.
Anyway, your basically saying that someone has a name (forename surname type affair)? And you want the forename and surname (name1, name2) to be displayed on the page?
hi yes thats why I am doing a name1, name2, name3 approach instead.
that is exactly what i want
This topic is now closed. New replies are no longer allowed.