SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql datbase to webpape

    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:

    Code:
    $sql = "SELECT name users WHERE username = '" . $_SESSION['username'] . "'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    echo "Hello, " . $row['name'] . ").";
    Thanks

  2. #2
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by condy View Post
    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:

    Code:
    $sql = "SELECT name users WHERE username = '" . $_SESSION['username'] . "'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    echo "Hello, " . $row['name'] . ").";

    Thanks

    Hold on...

    "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).???
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  3. #3
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by condy View Post
    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?
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  5. #5
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi yes thats why I am doing a name1, name2, name3 approach instead.

    that is exactly what i want


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •