Forum Moderators: coopster

Message Too Old, No Replies

Getting data from a particular row of a table in MySQL

Please Help!

         

nihal2000

12:56 pm on Jan 19, 2009 (gmt 0)

10+ Year Member



Hi guys i am new to this forum and PHP. I got stuck somewhere i need to display logged in persons detail from one of the table created in mySql database. By using sessions i am displaying username, but unable to understand how to get all the details displyed of the same user.
Please help me ......thank you very much!

andrewsmd

7:49 pm on Jan 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How is your table set up? I would use a mysql query to select any information you have on that user by using their session username. Basically when they login in set a variable to something like this.
if(they log in correctly){

//start the session
session_start();

$_SESSION['username'] = $_POST['username'];

}
Then whenever they go to another page just have a query like this

$query = "select myData from myTable where username = '{$_SESSION['username']}';"

nihal2000

2:00 pm on Jan 21, 2009 (gmt 0)

10+ Year Member



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 using session?
If possible please suggest me code, sorry but I am new to PHP……thanks a lot.

andrewsmd

2:41 pm on Jan 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you can post some of your login code I can give you more specific instructions. Do you anything about MySQL at all?

nihal2000

2:24 pm on Jan 22, 2009 (gmt 0)

10+ Year Member



Thanks my friend …………I managed to get it. But I definitely wanted to thanks you. I have a little bit knowledge about MySQL