Jump to content

Recommended Posts

Hi, I have a pretty decent newbie gallery now, just bare bones functionality, my next step I would like to do is take the images in a gallery collection, and link them to a user in the database, so that each user has their own gallery seen only to them. I don't know how I would do that. My user table fields are "user name" "name" "password" "email". I also have a gallery table. So I know I have to somehow, after the user logs on, encode any uploaded images with some unique identifier, then check that identifier every time a user enters the gallery page.. Any help greatly appreciated on how to approach this. Thank you. :)

Insert the primary key from the user's record in the users table as the owner id of each image in the gallery table. Then you'd just select the images for display that match the logged in user's id.

I added a field in the images (gallery) table. I called it "gallery_user". I want that to hold the user "id" primary key value when I upload each image. But I don't know how to do it.  I don't know how to put like , "upload this, and make the user "id" equal to the "gallery_user" field. Please any more help greatly appreciated.

 

For displaying the images, I somehow have to check "id" against "gallery_user" . but I don't know enough sql for that. lol. something like , output image WHERE gallery_user == id, but I know I can't do that in sql , I think. sorry.

 

EDIT: It looks like I use the JOIN command, not sure yet.

ok this is as far as I got. It doesn't work, does anyone know why please? thanks.

 

  
	$currentUser = $_SESSION['myusername'];
		 $userId =  mysql_query("SELECT id FROM users WHERE username = $currentUser");//get current session user name and get ID.
	    
	   mysql_query("INSERT INTO images (gallery_user) values ('$userId')");// insert current user id into gallery user.
	   																		//all based on the session user name

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.