4 Replies - 23022 Views - Last Post: 22 January 2009 - 07:12 AM Rate Topic: -----

#1 nihal   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-January 09

How to get particular users data using session after he logged in?

Post icon  Posted 21 January 2009 - 07:06 AM

I have a database called ‘hi_impact’ in that table name is ‘user_main’. In the table I have fields as id, username, password, first name, last name, company, city, state. When user logged in I am trying to display his first name, last name, company and city. Can you please explain me how to get data from database using session for the particular user?
Is This A Good Question/Topic? 0
  • +

Replies To: How to get particular users data using session after he logged in?

#2 pemcconnell   User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: How to get particular users data using session after he logged in?

Posted 21 January 2009 - 07:10 AM

You need to look up a PHP MySQL tutorial, paying particular attention to the WHERE clause in a SELECT statement

check this
Was This Post Helpful? 0
  • +
  • -

#3 Auzzie   User is offline

  • D.I.C Addict
  • member icon

Reputation: 43
  • View blog
  • Posts: 573
  • Joined: 20-January 09

Re: How to get particular users data using session after he logged in?

Posted 21 January 2009 - 08:15 AM

here is the SQL:
$query = mysql_query("SELECT first_name, last_name, company, city FROM user_main WHERE username = $_SESSION['username']");


This post has been edited by Auzzie: 21 January 2009 - 08:16 AM

Was This Post Helpful? 1
  • +
  • -

#4 kiwi2   User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 178
  • Joined: 16-September 08

Re: How to get particular users data using session after he logged in?

Posted 21 January 2009 - 09:44 AM

add to Auzzie's post
while($row = mysql_fetch_object($query) )
{
echo "$row->username<br />";

echo "$row->first_name<br />";

echo "$row->last_name<br />";

echo "$row->city<br />";
}
ect...
Was This Post Helpful? 1
  • +
  • -

#5 nihal   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-January 09

Re: How to get particular users data using session after he logged in?

Posted 22 January 2009 - 07:12 AM

Thanks guy's it helped me a lot...............thanks a lot!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1