943,822 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 3986
  • PHP RSS
May 14th, 2008
0

Display Username

Expand Post »
Here is what I am trying to accomplish: When a user logs in, their username will be displayed... Trouble is I am unsure how to co-relate the username w/ the id... thanks for any and all help....

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. require_once('core/db.php');
  3. require_once('core/secure.php');
  4.  
  5. $query = mysql_query("SELECT username FROM admin WHERE id = 1");
  6. $username = mysql_fetch_array($query);
  7. ?>
  8. <?php echo $username[username]; ?>
Similar Threads
Vai
Reputation Points: 12
Solved Threads: 5
Junior Poster in Training
Vai is offline Offline
74 posts
since Jan 2008
May 15th, 2008
1

Re: Display Username

php Syntax (Toggle Plain Text)
  1. <?php
  2. require_once('core/db.php');
  3. require_once('core/secure.php');
  4.  
  5. $query = mysql_query("SELECT username FROM admin WHERE id = 1");
  6. $result=mysql_query($query);
  7. $username=mysql_result($result,0,"username");
  8. ?>
  9. <?php echo $username; ?>

Enjoy!
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: File Upload Variables
Next Thread in PHP Forum Timeline: browser detect





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC