Page 1 of 1

Select from DB with sessions?

Posted: Sun Apr 25, 2010 4:48 am
by deiniolclarke
Hi there,

I'm pretty new to PHP. Basically, I'm making an online photo gallery. I'll have users on the site - I have that sorted (i.e. I've worked out how to create user login using sessions etc).

Anyway, once the user has logged in, I want them to be able to save 'favourite pictures' and to be able to view their favourites every time they log in using a mysql database. I can do that. But I'm having problems displaying the favourites from the database. I just can't work out a code / function to do it. So the fields in the database are id, username, password, name, email etc... Can I add a field to store the favourite pics in then recal it once they're logged into their session? I just can't connect the 'username' or any other identifyer with a 'favourites' field in the database.

Help much appreciated!!

Thanks,

Dan

Re: Select from DB with sessions?

Posted: Sun Apr 25, 2010 5:34 am
by requinix
You need another table.

The table has two fields: user ID and picture ID. With a JOIN you can get the user ID paired up with all the picture details and... I'm sure you can figure it out from there.