Select from DB with sessions?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deiniolclarke
Forum Newbie
Posts: 1
Joined: Sun Apr 25, 2010 4:41 am

Select from DB with sessions?

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Select from DB with sessions?

Post 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.
Post Reply