Reputation:
I am new here, and i got a bit of web development skills, and because in my new project I need User information on different bits of application, I was wondering is it all right to put the whole user row in a session array or to get data each time from database if so what is the easiest way to get a column (Cell) data based on ID from MYSQL with PHP ?
Thanks
Update: to be a bit more specific like i need usertype, name , email, msgs and stuff like this.
Upvotes: 0
Views: 3491
Reputation: 3785
$link = mysql_connect('localhost','root','yourPassword')
mysql_select_db('database',$link);
$sql = 'SELECT id FROM user'
$result = mysql_query($sql,$link);
$row = mysql_fetch_assoc($result);
$_SESSION['id']=$row['id'];
// put this id in session
Upvotes: 1
Reputation: 1492
Just put whatever you use on every page in the session, and get the other columns when you need them. Id assume the userid and username is what you would user every page.
Upvotes: 0